正如我在某处读到的,要在服务器启动时启动delayed_jobs,我应该在config / deploy.rb中写下以下内容:
require "delayed/recipes"
set :rails_env, "production" #added for delayed job
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"
它不起作用。事实上,我认为这个文件确实存在,但它不是(我捏造它)。 那么我该怎么做才能让它保持正常工作呢?
还有更多问题,如何在网络执行期间停止/重新启动作业处理?
答案 0 :(得分:0)
试试:
desc "Restart delayed_job process"
task :restart, :roles => :app do
run "cd #{current_path}; RAILS_ENV=production bundle exec script/delayed_job restart #{rails_env}"
end
这应该有效。