jmettraux/rufus-scheduler

SignalException - SIGTERM on Heroku

Closed this issue · 7 comments

Whenever my server restarts - during a deploy, and typically once per day automatically, I get a SIGTERM exception on scheduler.join

Anything we can do about this?

Hello,

you should not need to do scheduler.join. Remove that line. It is telling the Ruby main thread to join the rufus-scheduler thread, it is only used in example programs. It is not needed at all in "servers".

Closing the issue but not the conversation.

If I remove scheduler.join, the process cannot start and crashes - both locally and on Heroku.

Procfile

clock: bundle exec rake scheduler
14:14:23 clock.1   | booting scheduler...
14:14:24 clock.1   | exited with code 0
14:14:24 system    | sending SIGTERM to all processes

scheduler.rake

require 'rufus-scheduler'

task scheduler: :environment do

  $stdout.puts "booting scheduler..."

  scheduler = Rufus::Scheduler.new
  # tasks ommitted..
end

Basically I'm trying to run the scheduler in a separate process, independent of the rails app using Foreman. My tasks are super lightweight, all they do is queue a job to be run in the background via Sidekiq. Everything seems to work well with scheduler.join, except for the SIGTERM exceptions dirtying up my bug tracker.

Hello,

https://github.com/jmettraux/rufus-scheduler#getting-help

If I remove scheduler.join, the process cannot start and crashes - both locally and on Heroku.

How does it crashes? What error message locally? What error message on Heroku?

Warning: I am no Heroku specialist.

Thanks in advance.

Questions:

Whenever my server restarts - during a deploy, and typically once per day automatically, I get a SIGTERM exception on scheduler.join

Does that prevent the web part from executing correctly? Does that prevent the scheduling part from executing correctly? In other words, are those SIGTERM exceptions merely annoyances?

Also:

Could you please include the complete scheduler.rake, including its scheduler.join.

Thanks in advance.

Well I don't think its crashing, I think that without scheduler.join, the rake task finishes and exits immediately as there's nothing to keep it running.

Maybe rufus scheduler just needs to trap SIGTERM's and handle them gracefully? Everything works fine - merely annoyances. I think if I tried to do long running operations in the scheduler though, and a SIGTERM was received, it would quit without finishing, possibly causing issues.

Perhaps this is not a rufus-scheduler concern, see this section: https://devcenter.heroku.com/articles/dynos#graceful-shutdown-with-sigterm

Well I don't think its crashing

Then do not write "the process cannot start and crashes". Stick to the facts.

Perhaps this is not a rufus-scheduler concern, see this section:
https://devcenter.heroku.com/articles/dynos#graceful-shutdown-with-sigterm

OK. problem solved.

Best regards.