Stop a specific job upon deploying a new version of Sinatra app

57 views Asked by At

I have a rufus-scheduler job running in a Sinatra app (Phusion Passenger with NGINX). At the bottom of app.rb I have:

  scheduler.every '5m' do
    do_something_cool
  end

It get's the job running. But when I use Capistrano to update the app with a new version, I notice that the old job is still present and each run at the 5 minute interval.

How do I make sure that the old rufus-scheduler job is shutdown and the new one is started?

I've tried adding this at the bottom:

at_exit do
  if scheduler
    scheduler.shutdown
  end
end

But that did not work.

1

There are 1 answers

0
André Guimarães Sakata On

I'm not familiar with rufus-scheduler, but as I read in the documentation, it just uses threads for the schedule. So you just need to make sure your older process has been shut down.