简体   繁体   中英

Google Cloud Platform: How to run Ruby on Rails delayed_jobs automatically ( not using command line ) in production

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 :)

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM