mirror of
https://github.com/troglobit/finit.git
synced 2026-10-11 17:02:42 +07:00
Fix #299: add support for service readiness notification
This patch adds service readiness notification to support daemons employing systemd and s6 notification. Complementing the native Finit readiness support using PID files that exist already. The two have slightly different ways of implementing readiness: - https://www.freedesktop.org/software/systemd/man/sd_notify.html - https://skarnet.org/software/s6/notifywhenup.html Finit now provides both a NOTIFY_SOCKET environemnt variable, for systemd, and a way to start s6 daemons with a descriptor argument. For details on the syntax, see the `service` documentation. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -509,6 +509,20 @@ static void api_cb(uev_t *w, void *arg, int events)
|
||||
result = do_signal(rq.data, sizeof(rq.data), rq.runlevel);
|
||||
break;
|
||||
|
||||
case INIT_CMD_NOTIFY_SOCKET:
|
||||
svc = svc_find_by_pid(rq.runlevel);
|
||||
if (!svc) {
|
||||
errx(1, "Unknown PID, cannot register notify socket");
|
||||
result = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (uev_io_init(ctx, &svc->notify_watcher, service_notify_cb, svc, sd, UEV_READ)) {
|
||||
err(1, "Falied initializing %s readiness notifier", svc_ident(svc, NULL, 0));
|
||||
break;
|
||||
}
|
||||
return; /* Don't close sd, used for notify */
|
||||
|
||||
default:
|
||||
dbg("Unsupported cmd: %d", rq.cmd);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user