Saving rake work

I use delayed_job to run jobs, with each new job adding new jobs using cronjob.

I currently have a problem when rake jobs: work task, currently started with "nohup rake jobs: work &" manually, is accidentally deleted.

While God seems to be a solution for some people, the additional memory overhead is rather unpleasant, and I would prefer a simpler solution that can be restarted when the script (Capistrano) is deployed.

Is there any bash / Ruby magic to make this happen, or am I destined to start the monitoring service on my server with some terrible hacks to allow the unprivileged account that the site deploys to restart it?

+4
source share
4 answers

The delayed_job assume that you are using a monitoring service to manage work orders. I use runit - it works well.

(You can set it in the mode in which it does not replace init.)

Added:

Re: restart by Capistrano: yes, runit allows this. Just follow

sudo sv kill delayed_job

in your Capistrano recipe to kill a delayed_job worker. Runit will then restart it using the newly deployed code base.

0
source

For me, the demon gem was unreliable with delayed_job. Maybe a poorly written script (used the one that was on the delayed_job github page collective), and not demons, I'm not really sure. But for some reason, it will inadvertently restart during deployment.

I read that this was because he did not wait for the process to complete, so the pid files would be overwritten or something else. But I really did not bother to investigate. I switched to the daemons-spawn gem using these instructions and now it is much more reliable.

0
source

I performed a small rake task that restarts the task job again and again:

 desc "Start a delayed_job worker in a endless loop to prevent exits." task :jobs => :environment do while true begin Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY'], :quiet => false).start rescue Exception => e puts "Exception occured (#{e})" end puts "Task jobs:work exited, clearing queue and restarting" sleep 1 Delayed::Job.delete_all end end 

Apparently, this did not work. So I ended up with this simple solution:

 for (( ;; )); do rake jobs:work --trace; done 
0
source

get rid of deferred work and use whenever or resque

0
source

All Articles