initctl: status command formatting updates, add origin .conf file

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-03-04 07:27:06 +01:00
parent b3ea23ed26
commit fe27ed17eb
3 changed files with 19 additions and 6 deletions
+11 -3
View File
@@ -492,15 +492,23 @@ static int show_status(char *arg)
if (arg && arg[0]) {
long now = jiffies();
char buf[42] = "N/A";
char cmd[512];
svc = client_svc_find(arg);
if (!svc)
return 1;
printf("Service : %s\n", svc->cmd);
printf("Description : %s\n", svc->desc);
strlcat(cmd, svc->cmd, sizeof(cmd));
for (int i = 1; svc->args[i] && i < MAX_NUM_SVC_ARGS; i++) {
strlcat(cmd, " ", sizeof(cmd));
strlcat(cmd, svc->args[i], sizeof(cmd));
}
printf("Identity : %s\n", svc_ident(svc, ident, sizeof(ident)));
printf("Description : %s\n", svc->desc);
printf("Origin : %s\n", svc->file[0] ? svc->file : "built-in");
printf("Environment : %s\n", svc->env);
printf("Command : %s\n", cmd);
printf("PID : %d\n", svc->pid);
printf("Uptime : %s\n", svc->pid ? uptime(now - svc->start_time, buf, sizeof(buf)) : buf);
printf("Runlevels : %s\n", runlevel_string(runlevel, svc->runlevels));
@@ -760,7 +768,7 @@ int main(int argc, char *argv[])
{ "stop", do_stop },
{ "restart", do_restart },
{ "status", show_status },
{ "show", show_status }, /* Convenience alias */
{ "show", show_status }, /* Convenience alias, for now */
{ "ps", show_cgroup },
+2
View File
@@ -1162,6 +1162,8 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
strlcpy(svc->desc, desc, sizeof(svc->desc));
if (env)
parse_env(svc, env);
if (file)
strlcpy(svc->file, file, sizeof(svc->file));
/* Set configured limits */
memcpy(svc->rlimit, rlimit, sizeof(svc->rlimit));
+6 -3
View File
@@ -86,9 +86,8 @@ typedef enum {
typedef struct svc {
TAILQ_ENTRY(svc) link;
/* Instance specifics */
int job; /* JOB: */
char id[MAX_ID_LEN]; /* :ID */
/* Origin of service */
char file[MAX_ARG_LEN];
/* Limits and scoping */
struct rlimit rlimit[RLIMIT_NLIMITS];
@@ -110,7 +109,11 @@ typedef struct svc {
int sighup; /* This service supports SIGHUP :) */
svc_block_t block; /* Reason that this service is currently stopped */
char cond[MAX_COND_LEN];
/* Instance specifics */
int job; /* For intenal use only, canonical ref is NAME:ID */
char name[MAX_ARG_LEN];
char id[MAX_ID_LEN]; /* :ID */
/* Counters */
char once; /* run/task, (at least) once per runlevel */