8

我正在尝试让 Capistrano 使用 Rails 4 应用程序启动/停止延迟作业。我按照这里的说明进行操作,但它显示的是 Rails 3。这就是它现在的配置方式:

部署.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"

当我尝试部署时,在尝试执行RAILS_ENV=production script/delayed_job stop后出现以下错误

sh: script/delayed_job: not found
4

3 回答 3

18

找到了解决方法(set :delayed_job_command, "bin/delayed_job")并希望这对其他人有所帮助!

部署.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"
于 2013-09-12T19:11:48.423 回答
3

接受的答案对我也不起作用。我做了以下

部署.rb

def rails_env
  fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
end

execute "cd #{current_path};#{rails_env} bin/delayed_job restart"
于 2014-01-20T18:45:13.677 回答
1

对我来说,这行不通。我的生产环境由 ubuntu 12.04、rails 4、rbenv ruby​​ 2 和用于部署 capistrano 3 组成。在对每个适用的解决方案进行了大量处理之后,我在重新启动任务的 deploy.rb 中提出了这一行。

执行 :ruby, "/var/www/app/current/bin/delayed_job restart"

如此简单,但我花了 2 天时间才想出它。在我的设置中,我必须手动将 bin/delayed_job 放置到位。

希望其他人觉得这很有帮助。

于 2014-01-18T08:40:19.737 回答