My relationship with BackgrounDRb has been stormy. I loved how quickly it got me started with grabbing data for @oo5 - I installed the plugin, wrote a couple of workers and added the start script to my deply task. Easy. Except it never quite worked. Every couple of days one or more of my workers would fail. No errors in the logs but nothing firing. Maybe it was something I did but I couldn’t figure out how to debug the problem.
Without BackgrounDRb I would never have got @oo5 up and running but I finally decided it was time to give up and try something else. After loads of reading and a little asking around I decided to go go lo-fi: cron + script/runner.
Step 1 was the rolling of my BackgrounDRB workers into models - dead simple, nothing to write home about.
Step 2 was all about Cron… I’ve never liked Cron very much. I have never been able to remember how the triggers work and I was pretty keen not to have to wrangle yet another set of tricks. Luckily for me a compromise turned up in the shape of Cronedit, a gem to allow the editing of cron jobs from Ruby. My (Vlad) deply.rb now has a nice set of tasks for adding and removing jobs. In case you’re interested, here’s what mine looks like:
remote_task :add_tasks, :roles => :app do
CronEdit::Crontab.Add 'grab_from_twitter', {:minute => "1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57", :command => "#{deploy_to}/script/runner -e production 'Worker.grab_from_twitter'"}
end
Step 3? Profit. The new mechanism has been in place for a couple of weeks and it appears to be working without a hitch. Phew.