I am trying to get Capistrano to start/stop Delayed Jobs with a Rails 4 application. I followed the instructions here, but it says Rails 3. This is how its configured now:
deploy.rb:
require 'delayed/recipes'
after "deploy:start", "delayed_job:start"
after "deploy:stop", "delayed_job:stop"
after "deploy:restart", "delayed_job:stop","delayed_job:start"
When I try to deploy I get the following error after it tries to execute RAILS_ENV=production script/delayed_job stop
sh: script/delayed_job: not found
Found the workaround (set :delayed_job_command, "bin/delayed_job") and hope this helps someone else!
deploy.rb:
require 'delayed/recipes'
set :delayed_job_command, "bin/delayed_job"
after "deploy:start", "delayed_job:start"
after "deploy:stop", "delayed_job:stop"
after "deploy:restart", "delayed_job:stop","delayed_job:start"
The accepted answer did not work for me either. I did the following
deploy.rb
def rails_env
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
end
execute "cd #{current_path};#{rails_env} bin/delayed_job restart"
For me this didn't work. My production environment consists of ubuntu 12.04, rails 4, rbenv ruby 2, and for deployment capistrano 3. After messing around a lot with every applicable solution I've come up with this line in my deploy.rb in the restart task.
execute :ruby, "/var/www/app/current/bin/delayed_job restart"
so simple and yet it took me 2 days to come up with it. At my setup I had to manually put bin/delayed_job in place.
Hope someone else find this helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With