Class: Puma::Plugin::Systemd
- Inherits:
-
Object
- Object
- Puma::Plugin::Systemd
- Defined in:
- lib/puma/plugin/systemd.rb
Overview
Puma systemd plugin
Uses systemd notify to let systemd know a little about what puma is doing, so you know when your system has actually started and is ready to take requests.
Defined Under Namespace
Instance Method Summary collapse
-
#initialize(loader) ⇒ Systemd
constructor
Puma creates the plugin when encountering
pluginin the config. -
#start(launcher) ⇒ Object
We can start doing something when we have a launcher:.
Constructor Details
#initialize(loader) ⇒ Systemd
Puma creates the plugin when encountering plugin in the config.
17 18 19 20 |
# File 'lib/puma/plugin/systemd.rb', line 17 def initialize(loader) # This is a Puma::PluginLoader @loader = loader end |
Instance Method Details
#start(launcher) ⇒ Object
We can start doing something when we have a launcher:
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/puma/plugin/systemd.rb', line 23 def start(launcher) @launcher = launcher # Log relevant ENV in debug @launcher.events.debug "systemd: NOTIFY_SOCKET=#{ENV["NOTIFY_SOCKET"].inspect}" @launcher.events.debug "systemd: WATCHDOG_PID=#{ENV["WATCHDOG_PID"].inspect}" @launcher.events.debug "systemd: WATCHDOG_USEC=#{ENV["WATCHDOG_USEC"].inspect}" # Only install hooks if the system is booted by systemd, and systemd has # asked us to notify it of events. @systemd = Systemd.new if @systemd.booted? && @systemd.notify? @launcher.events.debug "systemd: detected running inside systemd, registering hooks" register_hooks # In clustered mode, we can start the status loop early and watch the # workers boot start_status_loop_thread if clustered? start_watchdog_loop_thread if @systemd.watchdog? else @launcher.events.debug "systemd: not running within systemd, doing nothing" end end |