I had first tested the Glassfish approach of running an Java application server. And although it isn't hard at all, as illustrated by Charles Nutter in his post correctly titled "Zero to Production in 15 Minutes", it wasn't practical for me: just running Glasfish consumed 300MB of RAM and impossible to run on my development machine. So I had to look somewhere else.
That's how I found Jetty-Rails.The way to run your JRuby on rails apps is so simple I thought their documentation was lacking! But it is really as simple as installing the jetty_rails gem!
The only missing piece were recipes and scripts to start, stop and restart the application when deploying with Capistrano. It was a simple matter of writing 2 scripts and the Capistrano recipe, with some experimentation in between I must admit :-)
Anyway, here are the scripts. The pid of the running jerry_rails process is stored in the file shared/tmp/pids/jetty_rails.pid.
script/spin
script/stop_jetty
There's a config file shared by these 2 scripts, put in script/jetty_config:
Put this in config/deploy.rb:
Notes
The start recipe is overwritten to add the option :pty => true. Without that option the nohup command isn't effective.
Using the nohup command is needed because there's currently no way to send the process to the background as a daemon, nor to store the PID in a specific file. These scripts do both.
No comments:
Post a Comment