我正在研究并发现很难找到一种主流方式来启动延迟工作宝石的工作人员。到目前为止,我有一个使用 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
一整天都在控制台?