Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

explicitly exit(0) on SIGTERM; keep it simple and trap less signals

Thanks to Brandon Keepers and Paul Gideon Dann for reporting that
`Process.kill :TERM, $$' does not work reliably.

For now, we will just exit(0) since that really won't do any harm.

Also, removed unnecessary traps on INT and QUIT.
  • Loading branch information...
commit b947840afccc883f338ddb8ad78b02280b62d725 1 parent ef64bbe
guns authored
Showing with 12 additions and 13 deletions.
  1. +12 −13 lib/delayed/daemon_tasks.rb
View
25 lib/delayed/daemon_tasks.rb
@@ -38,7 +38,7 @@
$0 = "delayed_worker.#{id}"
# reset all inherited traps from main process
- [:CLD, :HUP, :TERM, :INT, :QUIT].each { |sig| trap sig, 'DEFAULT' }
+ [:CLD, :HUP, :TERM].each { |sig| trap sig, 'DEFAULT' }
# lay quiet for a while before booting up if specified
sleep delay if delay
@@ -119,21 +119,20 @@
end
# terminate children on user termination
- [:TERM, :INT, :QUIT].each do |sig|
- trap sig do
- rails_logger.call "SIG#{sig} received! Shutting down workers."
+ trap :TERM do
+ rails_logger.call 'SIGTERM received! Shutting down workers.'
- # reset trap handlers so we don't get caught in a trap loop
- [:CLD, sig].each { |s| trap s, 'DEFAULT' }
+ # reset trap handlers so we don't get caught in a trap loop
+ [:CLD, :HUP, :TERM].each { |s| trap s, 'DEFAULT' }
- # kill the children and reap them before terminating
- Process.kill :TERM, *children.keys
- Process.waitall
- rails_logger.call "All workers have shut down."
+ # kill the children and reap them before terminating
+ Process.kill :TERM, *children.keys
+ Process.waitall
+ rails_logger.call 'All workers have shut down. Exiting.'
- # propagate the signal like a proper process should
- Process.kill sig, $$
- end
+ # TODO: investigate why some users are reporting that
+ # `Process.kill :TERM, $$' isn't working
+ exit
end
# NOTE: We want to block on something so that Process.waitall doesn't
Please sign in to comment.
Something went wrong with that request. Please try again.