mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
Always append /ID to cond if run/task/service is declared with :ID
This patch is a follow-up to the idea introduced in 1d6737e, but this
time we make sure to always append the svc ID to conditions if their
.conf has been declared with :ID
Meaning, the following .conf:
service :0 /sbin/teamd --config-file /etc/teamd-lag0.conf
service :1 /sbin/teamd --config-file /etc/teamd-lag0.conf
results in the following two conditions:
svc/sbin/teamd/0
svc/sbin/teamd/1
With a custom 'name:foo':
service name:lag :0 /sbin/teamd
service name:lag :1 /sbin/teamd
the resulting conditions look even prettier:
svc/lag/0
svc/lag/1
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
+7
-1
@@ -83,7 +83,7 @@ char *mkcond(svc_t *svc, char *buf, size_t len)
|
||||
|
||||
/* Custom name:foo declaration found => svc/foo instead of /svc/bin/path/pidfile-.pid */
|
||||
if (strcmp(nm, svc->name)) {
|
||||
snprintf(buf, len, "svc/%s/%s", svc->name, svc->id);
|
||||
snprintf(buf, len, "svc/%s", svc->name);
|
||||
_d("Composed condition from svc->name %s => %s", svc->name, buf);
|
||||
} else {
|
||||
snprintf(buf, len, "svc%s%s%s", path[0] != 0 && path[0] != '/' ? "/" : "", path, ptr);
|
||||
@@ -100,6 +100,12 @@ char *mkcond(svc_t *svc, char *buf, size_t len)
|
||||
if (ptr && !strcmp(ptr, ".pid"))
|
||||
*ptr = 0;
|
||||
|
||||
/* Always append /ID if service is declared with :ID */
|
||||
if (svc->id[0]) {
|
||||
strlcat(buf, "/", len);
|
||||
strlcat(buf, svc->id, len);
|
||||
}
|
||||
|
||||
_d("Creating condition => %s", buf);
|
||||
|
||||
return buf;
|
||||
|
||||
Reference in New Issue
Block a user