Wednesday, August 6, 2008

Craken: Manage And Install Rake-Centric Cron Jobs

Doug McInnes, who survived the experience when Hurricane Giles passed through his workplace, created an excellent plugin and finally open-sourced it.

Here’s the deal: with many web applications comes the need to do recurring tasks on the servers the application runs on. These sorts of tasks can range from running backups, clearing caches, emailing notices and other such maintenance-y things.

Who manages these tasks? Ideally the task code as well as configuration and timing should be kept with the source code of the application itself and not as part of some further set of scripts that reside in a dubious location in your source control. This is what Craken does.

The tasks are defined as rake tasks within the application. Craken itself is a rake task that sets up a crontab for defined tasks based on your current application configuration. The plugin also includes a Capistrano recipe that runs the Craken rake task on remote servers, making deployment a breeze.


Very handy, and, if I remember what Doug told me correctly, a nice practical example of code generation.

Here's the blog post; here's the repo on github.