måndag, maj 07, 2007

Announcing mongrel_jcluster

As I mentioned in my last post, that server/client thing wasn't the only thing I worked on during the flight. I also did a very useful hack of mongrel_cluster, and turned it into mongrel_jcluster. It's not very large changes, actually... Almost everything is the same, except that this mongrel plugin only runs in JRuby, and will start several mongrels in the same JVM.

jruby -S gem install mongrel_jcluster
cd your_rails_app
jruby -S mongrel_rails jcluster::configure -p 4000 -N 3 -e production -R 20202 -K thesecretkey
jruby -S mongrel_rails jcluster::start

The only difference in the configuration parameters are -R and -K which is the JRuby server port and key respectively. Now, after executing these commands, it will take some time for the mongrels to get online, so be patient (or monitor the progress in the log-files generated).

I need to warn you that this is still quite experimental and not guaranteed to work in any way. =) But it does for me.

Another thing, if you start Mongrel in production mode, the defualt Rails front-page will give you an error if you try to get at the properties. This is the expected behavior in production mode, though, and nothing wrong with JRuby.

4 kommentarer:

Robert Dempsey sa...

Ola,

When I try to install the mongrel_jcluster gem (with JRuby 1.0.0RC2), it barfs on the fastthread install (for mongrel). Any suggestions? Thanks for the help.

Ola Bini sa...

Ah, yeah, I should have made that clear. You _don't_ need to install the fastthread gem (it won't work anyway). It's purely optional, and in fact JRuby includes a fastthread implementation by default.

Arun Gupta sa...

I installed mongrel_jcluster on Windows Vista. A 2 pack Mongrel cluster is configured correctly but starting the cluster gives the following error:

C:\workspaces\jruby-trunk\samples\rails\hello>..\..\..\bin\jruby -S mongrel_rails jcluster::start
** Ruby version is not up-to-date; loading cgi_multipart_eof_fix
Starting JRuby server...
The system cannot find the path specified.
''' is not recognized as an internal or external command,
operable program or batch file.
Starting 2 Mongrel servers...
'sh' is not recognized as an internal or external command,
operable program or batch file.
mongrel_rails start -e development -p 8000 -P log/mongrel.8000.pid

'sh' is not recognized as an internal or external command,
operable program or batch file.
mongrel_rails start -e development -p 8001 -P log/mongrel.8001.pid

Marc sa...

For me, it ends up with:

/mongrel_jcluster/init.rb:36:in `start': Cannot run program "/bin/sh": java.io.IOException: error=12, Cannot allocate memory (IOError)