Conversation
|
The first commit here is unrelated to the purpose of this PR, it's just so my editor (as well as other present and future contributors) does not try to fix trailing whitespace as part of other commits, cluttering the diffs. That way, the important diffs would be easier to read for everyone. In particular, distro packagers try to read the changes from release to release before uploading the updated package. |
|
I'm not sure if tayga should exit if the pidfile exists with a valid pid. If tayga crashes (and thus doesn't delete the pidfile), then the service manager might restart tayga and get into a crash-loop. For reference, freeradius and nginx each write the pidfile unconditionally. |
That would be unrealistic as far as I understand. Service managers do auto-restart services, but don't need pidfiles. Non-managing launchers do use pidfiles, but can not auto-restart services. So here's my understanding. A classic init script is not a process supervisor, its job is to fork away & exit (and trust that the daemon does everything else correctly; many do not). It manages nothing. Among web backend developers of yore, a great selling point of process supervisors (even before it became popular in Linux-land to run the entire system under one) was that they had the capability to auto-restart their website backends, unlike the init system, in hope that the custom backend program does not immediately crash again, so service downtime would be reduced or feel non-existent.
Interesting! They might be relying on something else to kill whatever PID is in the pidfile already, though. |
I think this is an argument for Tayga to just overwrite the pidfile, since the only time it's started is when the system boots or the administrator explicitly calls the |
|
Fixed whitespace separately in #134 |
The whole point of a pidfile, in the absence of a service supervisor, is for a starting process in a non-interactive job (service) to detect other instances of that job (service), although not very robustly due to toctou, pid rollovers. If, at tayga start, the pidfile exists and contains a PID of an existing process, that is a sign we should bail out. Take care to remove the pidfile on exit. Use the pidfile to determine already-running and concurrently-launched tayga processes that point to the same pidfile. Lock the pidfile while writing our PID to it.
Thank you! Rebasing on top of main. |
82f334b to
c6cd005
Compare
The whole point of a pidfile, in the absence of a service supervisor, is for a starting process in a non-interactive job (service) to detect other instances of that job (service), although not very robustly due to toctou, pid rollovers. If, at tayga start, the pidfile exists and
contains a PID of an existing process, that is a sign we should bail out.
Take care to remove the pidfile on exit.
Use the pidfile to determine already-running and concurrently-launched
tayga processes that point to the same pidfile.
Lock the pidfile while writing our PID to it.