mirror of
https://github.com/troglobit/finit.git
synced 2026-10-12 10:12:32 +00: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:
+9
-2
@@ -63,6 +63,7 @@ static int pidfile_add_path(struct iwatch *iw, char *path)
|
||||
|
||||
static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
|
||||
{
|
||||
char ready[MAX_COND_LEN];
|
||||
char cond[MAX_COND_LEN];
|
||||
char fn[PATH_MAX];
|
||||
svc_t *svc;
|
||||
@@ -80,8 +81,9 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
|
||||
}
|
||||
|
||||
dbg("Found svc %s for %s with pid %d", svc->name, fn, svc->pid);
|
||||
|
||||
snprintf(ready, sizeof(ready), "service/%s/ready", svc_ident(svc, NULL, 0));
|
||||
mkcond(svc, cond, sizeof(cond));
|
||||
|
||||
if (mask & (IN_CLOSE_WRITE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO)) {
|
||||
svc_started(svc);
|
||||
if (!svc_has_pidfile(svc)) {
|
||||
@@ -114,8 +116,13 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
|
||||
}
|
||||
|
||||
cond_set(cond);
|
||||
} else if (mask & IN_DELETE)
|
||||
if (!svc->notify)
|
||||
cond_set(ready);
|
||||
} else if (mask & IN_DELETE) {
|
||||
cond_clear(cond);
|
||||
if (!svc->notify)
|
||||
cond_set(ready);
|
||||
}
|
||||
}
|
||||
|
||||
/* synthesize events in case of new run dirs */
|
||||
|
||||
Reference in New Issue
Block a user