Running Resque Workers from Upstart + RVM

I recently had the task of getting resque workings to start from Ubuntu’s upstart daemon.

First I created a bash script with the following;


# Load RVM into the shell
source "$HOME/.rvm/scripts/rvm"

# Switch to the right RVM version
rvm 1.9.2

# CD to the rails app
cd /home/myapp/

# Start the resque workers
QUEUE=* /home/myapp/.rvm/gems/ruby-1.9.2-p180/bin/rake resque:work

Put the above contents in a file called in your home directory.
Then give it executable status!

chmod +x

Next, create a file called resque.conf in /etc/init (you’ll need sudo access).

description "my App resque workers
start on (net-device-up and local-filesystems)
stop on runlevel [016]
exec su -c "/home/myapp/" myappuser >> /home/myappuser/resque.log 2>&1

If you run into errors, you can take a peek at /home/myappuser/resque.log to debug the problem.

Good luck! :)

Leave a Reply

You must be logged in to post a comment.