正如我在某处读到的,要在服务器启动时启动延迟作业,我应该在 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"
它不工作。事实上,我认为这个文件之前确实存在,但事实并非如此(我创建了它)。那么我应该怎么做才能让它继续工作呢?
还有更多问题,我应该怎么做才能在 Web 执行期间停止/重新启动作业处理?