Delayed::Job with Sinatra

sinatra queueing

Mon May 18 23:02:23 -0700 2009

DJ is a great Rails plugin for running a worker queue through your database. But it only works with Rails… or does it?

Blake Mizerany put together a DJ on Sinatra sample app. This app does a simple, but crucially important, background job: translating a string of text to Pig Latin. See it in action on Heroku.

The summary: vendor the DJ plugin, add its lib dir to the load path, and require delayed_job. Plus a few bits of glue to make ActiveRecord go, and you’re off to the races.