mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
initctl: add the settings of a service to the JSON status
initctl -j status had the state of a service but little of how it is
set up. A program reading it could not tell how the service is
stopped, what scripts it runs, or how it signals readiness.
Add the settings: stop, reload, notify, remain, scripts, directories,
cgroup-config, rlimits, log or tty, provides, conflicts, if, groups,
capabilities, pam, name, id, protected, and nowarn. The restart
object also gets sec, respawn, and oncrash, and the state Finit keeps
for its own use goes in internal:
"stop": {
"signal": "SIGTERM",
"timeout": 3,
"scope": "pgroup"
},
"scripts": {
"exec-stop-post": { "command": "/bin/true", "timeout": 7 }
},
initctl reads the status over D-Bus first, so each setting is also a
property of org.finit.Service1. The new test checks that the JSON is
the same over D-Bus as over the initctl socket.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
12 files changed
+893
-29
No files matched your search
@@ -379,6 +379,77 @@ static inline int svc_has_cond(svc_t *svc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline const char *svc_scope_str(svc_scope_t scope)
|
||||
{
|
||||
switch (scope) {
|
||||
case SVC_SCOPE_PGROUP:
|
||||
return "pgroup";
|
||||
case SVC_SCOPE_PROCESS:
|
||||
return "process";
|
||||
case SVC_SCOPE_CGROUP:
|
||||
return "cgroup";
|
||||
case SVC_SCOPE_MIXED:
|
||||
return "mixed";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static inline const char *svc_notify_str(svc_t *svc)
|
||||
{
|
||||
switch (svc->notify) {
|
||||
case SVC_NOTIFY_NONE:
|
||||
return "none";
|
||||
case SVC_NOTIFY_PID:
|
||||
return "pid";
|
||||
case SVC_NOTIFY_SYSTEMD:
|
||||
return "systemd";
|
||||
case SVC_NOTIFY_S6:
|
||||
return "s6";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static inline const char *svc_oncrash_str(svc_t *svc)
|
||||
{
|
||||
switch (svc->oncrash_action) {
|
||||
case SVC_ONCRASH_REBOOT:
|
||||
return "reboot";
|
||||
case SVC_ONCRASH_SCRIPT:
|
||||
return "script";
|
||||
}
|
||||
|
||||
return "ignore";
|
||||
}
|
||||
|
||||
static inline const char *svc_preserve_str(svc_t *svc)
|
||||
{
|
||||
switch (svc->dir_preserve) {
|
||||
case SVC_DIR_PRESERVE_RESTART:
|
||||
return "restart";
|
||||
case SVC_DIR_PRESERVE_YES:
|
||||
return "yes";
|
||||
}
|
||||
|
||||
return "no";
|
||||
}
|
||||
|
||||
/* The conditions in provides, comma separated */
|
||||
static inline char *svc_provides_str(svc_t *svc, char *buf, size_t len)
|
||||
{
|
||||
int i;
|
||||
|
||||
buf[0] = 0;
|
||||
for (i = 0; i < svc->num_provides; i++) {
|
||||
if (i)
|
||||
strlcat(buf, ",", len);
|
||||
strlcat(buf, svc->provides[i], len);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static inline const char *svc_typestr(svc_t *svc)
|
||||
{
|
||||
switch (svc->type) {
|
||||
|
||||
Reference in new issue
Block a user