Looking at the daemon code, it doesn't seem like there is an obvious extension point for this purpose. However, I am wondering if (in a demonized process) it can capture the KILL / TERM signal that the daemons send when the “stop” occurs ...?
trap("TERM") do
end
Alternatively, you can set the at_exit hook: -
at_exit do
end
source
share