I'm using the ruby daemon gem. Wondering how I can add some extra steps to the stop action? Was hoping I could detect stop was called, and add some extra code to it. Anyone know how I can accomplish this?
+3
A:
Looking at the daemon gem code, it doesn't look like it has an obvious extension point for this purpose. However, I wonder if (in the daemonized process) you could trap the KILL/TERM signal that daemons sends when a 'stop' occurs...?
trap("TERM") do
# execute your extra code here
end
Alternatively you could install an at_exit hook :-
at_exit do
# execute your extra code here
end
floehopper
2009-02-12 22:59:36
at_exit worked just fine, thanks a lot.
gregf
2009-02-13 17:47:20
+2
A:
Rapleaf had a pretty good article on their blog about an extension to the Daemons gem that might be what you're looking for.
techpeace
2009-02-25 21:24:03