I want to have a custom "stop" script runit
(runsv
) to execute when having to stop/restart the process. Currently it simply kills the process, then runs the "finish" script. But in my case, my process spawns dynamically child processes, so instead of simple kill
, I need a "killtree"
to get rid of them. How do I do that?
I know it should be done through the control
options of runit but from reading the docs its not really clear to me how the stop script should be named 🙁
Best Answer
From the docs
That means you need to create a
service_name/control/X
, X being an executable that will run when you send the relatedsv
command to the service, like thed
command (down). If your script exits with status 0 it will not try to down the service itself.Basically you need an executable script on
/etc/sv/<service>/control/d
that will do whatever you want and kill the service, clean up pids and etc.