mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Fixes for systemd notify integration, #4488
This commit is contained in:
parent
40e82fa05d
commit
1d9800b0ce
4 changed files with 22 additions and 14 deletions
|
@ -1,15 +1,17 @@
|
|||
#
|
||||
# systemd unit file for CentOS 7+, Ubuntu 15.04+
|
||||
# This file tells systemd how to run Sidekiq as a 24/7 long-running daemon.
|
||||
#
|
||||
# Customize this file based on your bundler location, app directory, etc.
|
||||
# Put this in /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
|
||||
# Run:
|
||||
# Customize and copy this into /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
|
||||
# Then run:
|
||||
# - systemctl enable sidekiq
|
||||
# - systemctl {start,stop,restart,reload} sidekiq
|
||||
#
|
||||
# This file corresponds to a single Sidekiq process. Add multiple copies
|
||||
# to run multiple processes (sidekiq-1, sidekiq-2, etc).
|
||||
#
|
||||
# Use `journalctl -u sidekiq -rn 100` to view the last 100 lines of log output.
|
||||
#
|
||||
[Unit]
|
||||
Description=sidekiq
|
||||
# start us only once the network and logging subsystems are available,
|
||||
|
@ -25,20 +27,23 @@ After=syslog.target network.target
|
|||
# times! systemd is a critical tool for all developers to know and understand.
|
||||
#
|
||||
[Service]
|
||||
# You may want to use
|
||||
# Type=notify
|
||||
# to ensure service is not marked as started before it actually did.
|
||||
# Include sd_notify gem to send a message on sidekiq startup like
|
||||
# Sidekiq.configure_server do |config|
|
||||
# config.on(:startup) { SdNotify.ready }
|
||||
# end
|
||||
# to let systemd know when the service is actually started.
|
||||
Type=simple
|
||||
#
|
||||
# WARNING WARNING WARNING
|
||||
#
|
||||
# As of v6.0.6, Sidekiq automatically supports systemd's `notify` service
|
||||
# monitoring. If you are using an earlier version, change this to `Type=simple`.
|
||||
#
|
||||
# WARNING WARNING WARNING
|
||||
#
|
||||
Type=notify
|
||||
WatchdogSec=5
|
||||
|
||||
WorkingDirectory=/opt/myapp/current
|
||||
# If you use rbenv:
|
||||
# ExecStart=/bin/bash -lc 'exec /home/deploy/.rbenv/shims/bundle exec sidekiq -e production'
|
||||
# If you use the system's ruby:
|
||||
ExecStart=/usr/local/bin/bundle exec sidekiq -e production
|
||||
# If you use rvm in production, don't.
|
||||
|
||||
# use `systemctl reload sidekiq` to send the quiet signal to Sidekiq
|
||||
# at the start of your deploy process.
|
||||
|
|
|
@ -258,4 +258,3 @@ module Sidekiq
|
|||
end
|
||||
|
||||
require "sidekiq/rails" if defined?(::Rails::Engine)
|
||||
require "sidekiq/systemd"
|
||||
|
|
|
@ -389,3 +389,5 @@ module Sidekiq
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
require "sidekiq/systemd"
|
||||
|
|
|
@ -13,6 +13,7 @@ module Sidekiq
|
|||
# "It is recommended that a daemon sends a keep-alive notification message
|
||||
# to the service manager every half of the time returned here."
|
||||
ping_f = sec_f / 2
|
||||
Sidekiq.logger.info "Pinging systemd watchdog every #{ping_f.round(1)} sec"
|
||||
Thread.new do
|
||||
loop do
|
||||
Sidekiq::SdNotify.watchdog
|
||||
|
@ -24,11 +25,12 @@ 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(:terminate) do
|
||||
config.on(:shutdown) do
|
||||
Sidekiq::SdNotify.stopping
|
||||
end
|
||||
Sidekiq.start_watchdog if Sidekiq::SdNotify.watchdog?
|
||||
|
|
Loading…
Add table
Reference in a new issue