Due to voracious memory consumption issues that were bringing down the server, I had to upgrade the backgroundrb plugin inside a certain Rails app from version 0.2.1 (from Nov 06) to the latest svn trunk, which uses fork() and exec() properly, and seems to be a near-total rewrite. There were a lot of changes needed. Here is how it was done…
first clean out the old stuff and download from svn, then run the rake task which is supposed to give you test and config stubs…
$ cd vendor/plugins/
$ sudo gem install chronic packet
$ mv backgroundrb /tmp/backgroundrb-old~
$ svn co http://svn.devjavu.com/backgroundrb/trunk backgroundrb
$ cd ../..
$ mv config/backgroundrb.yml /tmp/backgroundrb.yml.save~
$ rake backgroundrb:setup
$ vi config/backgroundrb.yml
contents of config/backgroundrb.yml are now much different:
:backgroundrb:
:port: 11006
:ip: 0.0.0.0
:production:
:backgroundrb:
:port: 22992
:lazy_load: true #do no load models eagerly
:debug_log: false # disable log workers and other logging
:environment: production # use rails production environmentthe next was necessary because rake did not seem to give me an updated start/stop script. So I found by manually copying it from the plugin dir:
$ mv script/backgroundrb script/backgroundrb.old~
$ cp vendor/plugins/backgroundrb/script/backgroundrb script/
also use svn to make sure my externals definition gets the trunk from now on:
$ svn propset svn:externals vendor/plugins backgroundrb http://svn.devjavu.com/backgroundrb/trunk
and finally, the worker control code now is totally changed, and the Worker class itself needs to inherit from BackgrounDRb::MetaWorker now. Having taken care of these and a few other cleanups, we seem to be running with a much smaller footprint now.
Of course, in the process of doing this I realized we really should be using ar_mailer, which would be a much more appropriate tool for this purpose (but sadly, has little to do with pirates). Keeping in mind certain caveats with that, as well. So that project may take place on the next rainy day.