Starting background tasks with Capistrano

后端 未结 4 1869
南方客
南方客 2020-12-14 19:15

For my RubyOnRails-App I have to start a background job at the end of Capistrano deployment. For this, I tried the following in deploy.rb:

run \"nohup #{curr         


        
4条回答
  •  感情败类
    2020-12-14 19:38

    Do you want your Scheduler job to run continually in the background and get restarted when you run Capistrano?

    If so, then for that I use runit http://smarden.sunsite.dk/runit/ and DelayedJob http://github.com/Shopify/delayed_job/tree/master

    1. Install runit in the mode of not replacing init
    2. Add your background job as a runit service and add the log monitor for it from runit.
    3. Have Capistrano call sudo sv kill job_name to kill and restart the job.

    My backround job is an instance of the Rails plugin DelayedJob which handles background Rails tasks. I kill it with every Capistrano deploy so it will restart with the updated code base.

    This has proved to be very reliable.

    HTH,

    Larry

提交回复
热议问题