Closed hongkongkiwi closed 3 years ago
Oh I see, it's a little bit confusing in the docs, but from my understanding:
pid:
then finit creates and manages the pid
pid:!
then finit monitors the pid (but does not create or manage)
Yup, it's very confusing, but you got it. By default the PID file name for a monitored service is discovered by an inotify callback that reads the contents of PID files from /run and matches them with services. The special case for pid:!
is to cover directories that Finit does not monitor. (There is also a historical/legacy reason for it ...)
Subsequently I found this in pid.c which was helpful. Just a suggestion that maybe this can be in the docs:
/*
* This function parses a PID file @arg for @svc.
*
* The logic is explained below. Please note that using the first form
* of the syntax not only creates and removes the PID file, but it also
* calls touch to update the mtime on service_restart(), only applicable
* to processes that accept SIGHUP. This to ensure dependent services
* are sent SIGCONT properly on reload, otherwise their condition would
* never be asserted again after `initctl reload`.
*
* pid --> /run/$(basename).pid
* pid:foo --> /run/foo.pid
* pid:foo.pid --> /run/foo.pid
* pid:foo.tla --> /run/foo.tla.pid
* pid:/tmp/foo --> /tmp/foo.pid (Not handled by pidfile plugin!)
*
* An exclamation mark, or logial NOT, in the first character position
* indicates that Finit should *not* manage the PID file, and that the
* process uses a "non-standard" location. Eg. if service is 'bar'
* Finit would assume the PID file is /run/bar.pid and the below simply
* 'redirects' Finit to use the correct PID file.
*
* pid:!foo --> !/run/foo.pid
* pid:!/run/foo.pid --> !/run/foo.pid
*
* Note, nothing is created or removed by Finit in this latter form.
*/
The project is open to receive patches and pull requests to improve the documentation.
I notice that there are some places in the documentation where the syntax is:
pid:!/var/run/myapp.pid
and in another place it shows:
pid:/var/run/myapp.pid
What is the exclamation mark for? is this necessary?