0

我正在研究并发现很难找到一种主流方式来启动延迟工作宝石的工作人员。到目前为止,我有一个使用 Capistrano 的解决方案:

# add this to config/deploy.rb
namespace :delayed_job do
  desc "Start delayed_job process"
  task :start, :roles => :app do
    run "cd #{current_path}; script/delayed_job start #{rails_env}"
  end

  desc "Stop delayed_job process"
  task :stop, :roles => :app do
    run "cd #{current_path}; script/delayed_job stop #{rails_env}"
  end

  desc "Restart delayed_job process"
  task :restart, :roles => :app do
    run "cd #{current_path}; script/delayed_job restart #{rails_env}"
  end
end

after "deploy:start", "delayed_job:start"
after "deploy:stop", "delayed_job:stop"
after "deploy:restart", "delayed_job:restart"

但显然在某些情况下,Apache 用户与 Rails 应用程序用户不同,这会导致问题吗?有没有更好的方法来自动化工作流程,这样我就不必坐在我的电脑前打字了

$ RAILS_ENV=production script/delayed_job start
$ RAILS_ENV=production script/delayed_job stop

一整天都在控制台?

4

1 回答 1

0

我创建了一个 rake 任务来每天运行一次“rake:jobs workoff”。您可以根据需要经常设置。我使用了heroku调度程序。

于 2016-02-20T08:11:58.690 回答