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;

#!/bin/bash

# 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 resque.sh in your home directory.
Then give it executable status!

chmod +x resque.sh

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]
respawn
exec su -c "/home/myapp/resque.sh" 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! :)

Did you like this? Share it:

No related posts.



2 Responses to “Running Resque Workers from Upstart + RVM”

  1. These Cheap Packers Jerseys from our Chicago Bears Jerseys
    online shop will quickly make you really feel closer for your favorite crew while providing you the comfort to know you are obtaining the best of the most effective. You’ll be impressed with the quality and features of Chicago Bears Jerseys
    .

  2. [...] PHP TutorialsJigsaw Boys – Security, Network and Computer Tech Tip Database! [...]

Leave a Reply

You must be logged in to post a comment.