Blankman
Blankman

Reputation: 267030

Does delayed job run as a daemon?

It seems that delayed_job is a framework for scheduling tasks to be done (via a mysql db).

The actual processing is done via ruby, and that process doesn't run as a deamon correct?

i.e. it is up to us to somehow make the ruby fire via a cron job or?

Upvotes: 3

Views: 4317

Answers (1)

Luke Chadwick
Luke Chadwick

Reputation: 1737

Delayed Job does run as a process, and is even capable of running multiple workers.

Each of those processes fully loads your rails application - that can be less than ideal in many circumstances.

You can start delayed job with:

RAILS_ENV=production ruby script/delayed_job start -n 3

In my own projects I use bluepill to ensure that any workers that crash are restarted:

workers = 5
app_name = "my_app"
Bluepill.application("#{app_name}_delayed_job", :log_file => "#{app_home}/shared/log/bluepill.log") do |app|
  (0...workers).each do |i|
    app.process("delayed_job.#{i}") do |process|
      process.working_dir = "#{app_home}/current"

      process.start_grace_time    = 10.seconds
      process.stop_grace_time     = 10.seconds
      process.restart_grace_time  = 10.seconds

      process.start_command = "cd #{app_home}/current && RAILS_ENV=production ruby script/delayed_job start -i #{i}"
      process.stop_command  = "cd #{app_home}/current && RAILS_ENV=production ruby script/delayed_job stop -i #{i}"

      process.pid_file = "#{app_home}/shared/pids/delayed_job.#{i}.pid"
      process.uid = app_name # I install my applications under a user of the same name
      process.gid = app_name
    end
  end

Upvotes: 4

Related Questions