My foo-daemon needs some arguments and several steps to shutdown while saving its work. Like maybe kill -HUP, wait 10 seconds and then kill -9. Any suggestions that would be obvious to me without always having you for one-on-one consultation? Rare cases where saving work is not complete after 10 seconds are acceptable for my use case.
You can find this doc by typing "systemd.service" into your favorite search engine.
The title I link to is the simple case example, which explains just below the content sample that it has pretty much the behavior you want:
Since no ExecStop= was specified, systemd will send SIGTERM to all processes
started from this service, and after a timeout also SIGKILL. This behavior can
be modified, see systemd.kill(5) for details.
Per this, you can either implement SIGTERM rather than SIGHUP, or you can change the stop signal. It already has a generous shutdown timeout (on one of my systems where I have a similarly simple unit, it's defaulted to 1m30s). You can change the timeout by setting https://www.freedesktop.org/software/systemd/man/systemd.ser...
If your daemon needs kill -9 you fucked up but even then you can just set "stop timeout" and your demon will get the termination signal, and kill after that interval.
More crude option is putting all of the custom stop behaviour in ExecStop script
Hopefully this helps you skip the red tape.