TIL - SystemD and $MAINPID
TIL, Today I Learned, is more of a "I just figured this out: here are my notes, you may find them useful too" rather than a full blog post
A special environmnent variable, $MAINPID, is set and is available for the .service file. The variable exposes the MainPID property of the service and could be useful if your custom services e.g. forks.
This let you do
ExecReload=/bin/kill -HUP "$MAINPID"
To send a HUP signal to the main process created by your service.
You can read out the MainPID property of a process by using systemctl:
systemctl [--user] show --property MainPID --value <service>
Read more about it in the systemd.service manual [1].