module Puma::SdNotify
def self.notify(state, unset_env=false)
- See: https://www.freedesktop.org/software/systemd/man/sd_notify.html -
Raises:
-
(NotifyError)
- if there was an error communicating with the systemd
Returns:
-
(Fixnum, nil)
- the number of bytes written to the notification
Parameters:
-
unset_env
(Boolean
) -- -
state
(String
) --
def self.notify(state, unset_env=false) sock = ENV["NOTIFY_SOCKET"] return nil if !sock ENV.delete("NOTIFY_SOCKET") if unset_env begin Addrinfo.unix(sock, :DGRAM).connect { |s| s.write state } rescue StandardError => e raise NotifyError, "#{e.class}: #{e.message}", e.backtrace end end