Method: SdNotify.notify
- Defined in:
- lib/sd_notify.rb
.notify(state, unset_env = false) ⇒ Fixnum?
Notify systemd with the provided state, via the notification socket, if any.
Generally this method will be used indirectly through the other methods of the library.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/sd_notify.rb', line 106 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 do |s| s.close_on_exec = true s.write(state) end rescue StandardError => e raise NotifyError, "#{e.class}: #{e.message}", e.backtrace end end |