class SmartProxyDynflowCore::SdNotify
Public Instance Methods
active?()
click to toggle source
# File lib/smart_proxy_dynflow_core/sd_notify.rb, line 9 def active? !ENV['NOTIFY_SOCKET'].nil? end
notify(message)
click to toggle source
# File lib/smart_proxy_dynflow_core/sd_notify.rb, line 13 def notify(message) create_socket.tap do |socket| socket.sendmsg(message.chomp + "\n") # ensure trailing \n socket.close end end
ready(state = 1)
click to toggle source
# File lib/smart_proxy_dynflow_core/sd_notify.rb, line 20 def ready(state = 1) notify("READY=#{state}") end
Private Instance Methods
create_socket()
click to toggle source
# File lib/smart_proxy_dynflow_core/sd_notify.rb, line 26 def create_socket raise 'Missing NOTIFY_SOCKET environment variable, is this process running under systemd?' unless active? Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM, 0).tap do |socket| socket.connect(Socket.pack_sockaddr_un(ENV['NOTIFY_SOCKET'])) end end