I’ve been using a little tool named
rv for months now to robustly manage camping apps in deployment. It consists of an
init.d script, a default mongrel harness you can adjust to taste, and a
.yml file for each app.
download and installation
Download version 2 from the Snax Fauna, or check out the project from svn with:
svn co svn://rubyforge.org/var/svn/fauna/rv/rv
Next, make a folder
etc/init.d/rv to the
/etc/init.d/ folder. Change the
USER='httpd' near the top to the user the daemons should run as (never root!).
Install as a boot service (on Ubuntu) with:
$ sudo /usr/sbin/update-rc.d rv defaults
If you are not using Ubuntu you may have to do something different. Redhat uses
chkconfig. Gentoo uses something else yet probably. On OS X you can try to get
launchd to work, if you are bold.
Copy the included
harness/rv_harness.rb to your camping application’s folder. Edit it appropriately for your app and database.
Then, copy the example
etc/rv/my_blog.yml file into
/etc/rv. Rename and edit it appropriately for your app. You need to set the path, proxy port, and listen interface. For more apps, you can just add more
Now you can manually start, stop or restart all your camping daemons by calling:
$ sudo /etc/init.d/rv start $ sudo /etc/init.d/rv stop $ sudo /etc/init.d/rv restart
In most situations, you will also need an Apache vhost entry in
httpd.conf to reference the camping proxy started by
rv. Here’s one for Apache 2.2:
<VirtualHost *:80> ServerName myblog.j2ee.com ProxyRequests Off ProxyPass / http://127.0.0.1:3055/ ProxyPassReverse / http://127.0.0.1:3055/ ProxyPreserveHost On #Fix for Apache bug 39499 SetEnv force-proxy-request-1.0 1 SetEnv proxy-nokeepalive 1 </VirtualHost>
It would be really nice if someone could write a setup script for this, so you don’t have to copy stuff around by hand. It could ask you questions on initial setup, and then each time you want to add a new app.