4

当我将启动我的 Rails 服务器时,我想在我的生产中启动 script/delayed_job start。反正我能做到吗?

编辑::

我已将此行添加到我的 config/initializers/delayed_job.rb 。

Delayed::Worker.new.start 

但是当我运行我的 Rails 应用程序时,我的延迟作业服务器没有启动。有没有其他解决办法??

4

3 回答 3

0

You can setup an init.d file, but I would recommend either monit or god. God is ruby, so it is familiar, but that also means it leaks a bit. If you are going to run God, I recommend a cron job to restart it. This is a VERY good post on configuring monit on your server.

We went the God route, but if we had it to do over again - we would do monit.

于 2010-06-22T03:09:36.030 回答
0

I would recommend deploying your app with Capistrano and defining a after:deploy hook to start/restart DJ at every deploy.

I would also recommend using Resque over DelayedJob, as the latter has tendencies to just die without any reason, and usually requires a Monit/God monitoring and restarting it.

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"
于 2010-06-21T20:20:50.950 回答
-1

你可以做

Delayed::Worker.new.start

在您的初始化程序目录中(在其中创建一个新的“.rb”文件,它将从您的应用程序开始)

于 2010-06-21T20:08:01.727 回答