Q:

Managing multiple instances of Resque and Redis

I am trying to have God monitor two instances of Resque, one for production and one for staging.
So I start two Redis instances on system boot: redis_6379 and redis_6380.
Then I'm using Daemontools to start and monitor God. 
My God script looks something like this:
God.watch do |w|
  w.dir      = "#{rails_root}"
  w.name     = "resque-#{num}"
  w.group    = 'resque'
  w.interval = 30.seconds
  w.env      = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env}
  w.start    = "rake resque:work QUEUE='*' RAILS_ENV=#{rails_env}"
  ....
end

Don't I need to somehow associate the staging and production resque processes with particular redis instances?
I'm gradually piecing this together but I think I'm missing a key piece.
Thanks in advance

A:

First, you don't need to specify QUEUE and RAILS_ENV in w.start since you already specified them in a proper place, w.env.
Second, this script runs a single instance of resque in a rails_env environment (whatever its value is).
I suggest something like this:
%w(staging production).each do |rails_env|
  God.watch do |w|
    w.dir      = "#{rails_root}" # <= is this path the same for production and staging?
                                 # if not, change accordingly.
    w.name     = "resque-#{rails_env}"
    w.group    = 'resque'
    w.interval = 30.seconds
    w.env      = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env}
    w.start    = "rake resque:work"
    ....
  end
end

