1

We have been able to successfully run delayed jobs in development mode using rake:jobs work

We have deployed our Rails application to google cloud platform and we are not sure How to run delayed_jobs automatically ( not using command line ) in production

If we run localhost production server and manually run ruby bin/delayed_job run ( for windows) it works We are not sure how to achieve this automatically without using command line.

Any help is appreciated :)

ashai
  • 11
  • 1
  • 2

1 Answers1

0

Refer this link to run delayed job automatically when server starts without running manually on console rake jobs:work

Start or ensure that Delayed Job runs when an application/server restarts

Note: deamons gem dosen't work for windows but the same will run on linux or mac

OR

copy the code into your initializers/delayed_job_config.rb

DELAYED_JOB_PID_PATH = "#{Rails.root}/tmp/pids/delayed_job.pid"

def start_delayed_job
  Thread.new do
    `ruby bin/delayed_job start`
  end
end

def daemon_is_running?
  pid = File.read(DELAYED_JOB_PID_PATH).strip
  Process.kill(0, pid.to_i)
  true
rescue Errno::ENOENT, Errno::ESRCH   # file or process not found
  false
end

start_delayed_job unless daemon_is_running?
Community
  • 1
  • 1
ashai
  • 11
  • 1
  • 2