mirror of
https://github.com/troglobit/finit.git
synced 2026-10-08 16:34:45 +07:00
Improve logging of forking services having started and stopped
Since a forking service, e.g. a sysv init script, will exit very early we cannot log the same as for regular services "Starting foo[123]", so instead we log "Started bar[321]" when we get the pidfile update and the same when stopping a forking service, log "Stopped bar[321]" when we collect the PID. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -102,6 +102,9 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
|
||||
_d("Forking service %s changed PID from %d to %d",
|
||||
svc->cmd, svc->pid, pid);
|
||||
svc->pid = pid;
|
||||
|
||||
/* Complement log in service.c for non-forking services */
|
||||
logit(LOG_CONSOLE | LOG_NOTICE, "Started %s[%d]", svc_ident(svc, NULL, 0), pid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -1537,11 +1537,17 @@ void service_monitor(pid_t lost, int status)
|
||||
}
|
||||
|
||||
/* Forking sysv/services declare themselves with pid:!/path/to/pid.file */
|
||||
if (svc_is_starting(svc) && svc_is_forking(svc)) {
|
||||
svc->pid = 0; /* Expect no more activity from this one */
|
||||
return;
|
||||
if (svc_is_forking(svc)) {
|
||||
/* Likely start script exiting */
|
||||
if (svc_is_starting(svc)) {
|
||||
svc->pid = 0; /* Expect no more activity from this one */
|
||||
return;
|
||||
}
|
||||
|
||||
logit(LOG_CONSOLE | LOG_NOTICE, "Stopped %s[%d]", svc_ident(svc, NULL, 0), lost);
|
||||
}
|
||||
|
||||
|
||||
/* Terminate any children in the same proess group, e.g. logit */
|
||||
kill(-svc->pid, SIGKILL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user