I am deploying a project to a environment where multiple application is deployed. So I uses rvm to separated the running environment of each Rails application.
In my application, I use gem god
to manage my delayed_job processes, in my god file I had:
God.watch do |w|
...
w.start = "RAILS_ENV=#{RAILS_ENV} /usr/local/rvm/bin/rvm in #{RAILS_ROOT} do #{RAILS_ROOT}/script/delayed_job -n 1 start"
...
end
but for this, God reports:
/usr/local/rvm/gems/ruby-1.9.3-p327-falcon@global/gems/god-0.13.2/lib/god/process.rb:324:in `exec': No such file or directory - RAILS_ENV=staging /usr/local/rvm/bin/rvm in /home/deployer/deploy/myproject/current do /home/deployer/deploy/myproject/current/script/delayed_job stop (Errno::ENOENT)
And if I change it to:
w.start = "export RAILS_ENV=#{RAILS_ENV} /usr/local/rvm/bin/rvm in #{RAILS_ROOT} do #{RAILS_ROOT}/script/delayed_job -n 1 start"
it works. I would like to know if added export
is the correct way to do it in a multiple application environment, since on that server, there a other applications runs under RAILS_ENV=production
, will them be affected?
UPDATE
I just found that I was wrong, with adding export
to the beginning, God
still throws me the same error, how could I achieve this?
Thanks & Best Regards.
Finally I learnt that I have to do it like this:
w.start = "/usr/bin/env RAILS_ENV=#{RAILS_ENV} /usr/local/rvm/bin/rvm in #{RAILS_ROOT} do #{RAILS_ROOT}/script/delayed_job -n 1 start"
Then it's ok.