Personal website of developer Filip Stefansson / Archive

delayed_job with Dokku and Shoreman

(If you’re not familiar with Dokku, you can find an awesome guide here)

(If you’re not familiar with delayed_job, you can find an awesome guide here)

If you’re using Dokku to deploy your Ruby on Rails app you might have noticed that Dokku only runs the web process(which is basically the regular rails s) by default.

So if you’re using something like delayed_job, you probably want to set up a worker that runs that process. So how is this possible with Dokku?

Meet Shoreman

Shoreman let’s you run any type of process from the Procfile. It’s a Dokku plugin and it’s really easy to get up and running.

Here’s what you got to do on the production server:

git clone https://github.com/statianzo/dokku-shoreman.git /var/lib/dokku/plugins/dokku-shoreman

Create a Procfile

Create a file falled Procfile in the root folder of your project. This file will tell Shoreman what processes to start when you deploy. Edit the file to look like this:

web: bundle exec rails server -p $PORT
worker: bundle exec rake jobs:work

When we create the Procfile, we also take on the responsibility to start the Rails server, which we’re doing on line 1. If you don’t do this, you will get a 502 error since the server won’t be running.

All you have to do now is to push like you’re used to:

git push dokku master

Alternatives to Shoreman

There are other Dokku plugin for process handeling, like the more popular one; Supervisord, or the less popular one Circus.

More articles →