Is it possible to execute custom code when God restarts a process. Please see sample below of what I mean. When watch transitions from :up to :start (process restarted), we want to send a log to syslog at :error level. applog is a method defined in God module.
w.transition(:up, :start) do |on|
applog(w, :error, "critical server process exited")
on.condition(:process_exits) do |c|
c.notify = 'alerts'
end
end
Currently, I see message in syslog when the watch config is loaded. How else can I log an error in syslog on a certain transition?
I tried adding a new Contact in God by defining a Contact and loading via God.contact(). Ran into errors around missing name, etc. Not sure how else to register. Better way would be to fork the gem and add a new Contact, however that would mean changing a lot in our infra. Approach below is what I ended up using for now....involves monkey patching.