1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Rework systemd integration so it does not activate when run in other binaries, like sidekiqswarm or a custom Sidekiq launcher, #4511

This commit is contained in:
Mike Perham 2020-03-26 13:07:45 -07:00
parent b48d539b9b
commit 2504d0b7ac
3 changed files with 21 additions and 15 deletions

View file

@ -6,6 +6,7 @@ HEAD
---------
- Fix: Do not connect to redis at ruby vm exit when not needed. [#4502]
- Refactor systemd integration to work better with custom binaries [#4511]
- Remove Redis connection naming [#4479]
6.0.6

View file

@ -6,9 +6,28 @@ $TESTING = false
require_relative '../lib/sidekiq/cli'
def integrate_with_systemd
return unless ENV["NOTIFY_SOCKET"]
Sidekiq.configure_server do |config|
Sidekiq.logger.info "Enabling systemd notification integration"
require "sidekiq/sd_notify"
config.on(:startup) do
Sidekiq::SdNotify.ready
end
config.on(:shutdown) do
Sidekiq::SdNotify.stopping
end
Sidekiq.start_watchdog if Sidekiq::SdNotify.watchdog?
end
end
begin
cli = Sidekiq::CLI.instance
cli.parse
integrate_with_systemd
cli.run
rescue => e
raise e if $DEBUG

View file

@ -16,23 +16,9 @@ module Sidekiq
Sidekiq.logger.info "Pinging systemd watchdog every #{ping_f.round(1)} sec"
Thread.new do
loop do
Sidekiq::SdNotify.watchdog
sleep ping_f
Sidekiq::SdNotify.watchdog
end
end
end
end
if ENV["NOTIFY_SOCKET"]
Sidekiq.configure_server do |config|
Sidekiq.logger.info "Enabling systemd notification integration"
require "sidekiq/sd_notify"
config.on(:startup) do
Sidekiq::SdNotify.ready
end
config.on(:shutdown) do
Sidekiq::SdNotify.stopping
end
Sidekiq.start_watchdog if Sidekiq::SdNotify.watchdog?
end
end