Skip to content

Commit

Permalink
coexist with other signal handlers (#4991)
Browse files Browse the repository at this point in the history
* coexist with other signal handlers

* don't allow error from old handler to disrupt sidekiq signal handling

* changelog
  • Loading branch information
jjb committed Sep 13, 2021
1 parent ab90830 commit 582b57a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changes.md
Expand Up @@ -22,6 +22,8 @@ require "sidekiq/middleware/current_attributes"
Sidekiq::CurrentAttributes.persist(Myapp::Current) # Your AS:CurrentAttributes singleton
```
- Retry Redis operation if we get an `UNBLOCKED` Redis error. [#4985]
- **BREAKING CHANGE** Run existing signal-handling code, if there is any, before running sidekiq's
signal-handling code. [#4991]

6.2.2
---------
Expand Down
9 changes: 8 additions & 1 deletion lib/sidekiq/cli.rb
Expand Up @@ -46,7 +46,14 @@ def run(boot_app: true)
# USR1 and USR2 don't work on the JVM
sigs << "USR2" if Sidekiq.pro? && !jruby?
sigs.each do |sig|
trap sig do
old_handler = Signal.trap(sig) do
if old_handler.respond_to?(:call)
begin
old_handler.call
rescue Exception
puts $!.inspect
end
end
self_write.puts(sig)
end
rescue ArgumentError
Expand Down

0 comments on commit 582b57a

Please sign in to comment.