Class: SmartProxyDynflowCore::SdNotify

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_proxy_dynflow_core/sd_notify.rb

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/smart_proxy_dynflow_core/sd_notify.rb', line 9

def active?
  !ENV['NOTIFY_SOCKET'].nil?
end

#notify(message) ⇒ Object



13
14
15
16
17
18
# 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) ⇒ Object



20
21
22
# File 'lib/smart_proxy_dynflow_core/sd_notify.rb', line 20

def ready(state = 1)
  notify("READY=#{state}")
end