If you have any sort of jobs you need run on a regular basis for your rails app, I can highly recommend the whenever gem. Make a schedule.rb file with all your cron jobs in a pleasent ruby DSL, it's lovely! Every time you deploy, you can setup a hook in whatever deploy process you're using (chef, capistrano) to run the "Whenever" executable script and update your crontab. Sweet!
But we've had a problem recently when we deployed our app to Engineyard AppCloud. We put in a deploy hook to run the whenever script, so far so good. The only problem was deployment wasn't the only time that we needed our crontab updated. You see, as with most cloud setups, we could rebuild our cluster at anytime to make configuration changes or what have you, and it should pick up where it left off. That would bring our code back, but our crontab would be squeaky clean (we found that out the hard way when we rebuilt our cluster and suddenly our billing jobs weren't running).
Fortunately, engineyard uses Chef for their cluster configuration, and they provide you a way to apply Custom Chef Recipes to your environments that will do things during your cluster rebuild.
Taking advantage of this, I built a small custom recipe for "whenever" that simply executes the whenever script in your current app directory (only if it's a utility instance or a solo instance, so your app servers aren't running your big jobs). Check it out at this gist!
Also, if you'd like to see it in it's native environment as part of your ey-cloud-recipes project, you can check out our public git repo Here (recipe is in /cookbooks/whenever/recipes/default.rb).
Cheers!
Friday, October 29, 2010
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment