mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
Fix #197: initctl status foo should show overview of foo:1, foo:2 ..
When the system has multiple services 'foo' the initctl command 'status foo' should give a focused overview of all matching foo:*, whereas a 'status foo:2' should show the detailed view of that particular instance. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+5
-1
@@ -132,7 +132,11 @@ Reload service by name (SIGHUP or restart)
|
||||
.It Nm Ar restart Cm NAME[:ID]
|
||||
Restart (stop/start) service by name
|
||||
.It Nm Ar status Cm NAME[:ID]
|
||||
Show service status, by name
|
||||
Show service status, by name. If only
|
||||
.Cm NAME
|
||||
is given and multiple instances exits, a summary of all matching
|
||||
instances are shown. Only an exact match displays the detailed status
|
||||
for a particular instance
|
||||
.It Nm Ar status
|
||||
Show status of all services, default command
|
||||
.It Nm Ar cgroup
|
||||
|
||||
+18
-3
@@ -703,18 +703,31 @@ static int show_status(char *arg)
|
||||
{
|
||||
char ident[MAX_IDENT_LEN];
|
||||
char buf[512];
|
||||
int num = 0;
|
||||
svc_t *svc;
|
||||
|
||||
runlevel = runlevel_get(NULL);
|
||||
|
||||
if (arg && arg[0]) {
|
||||
while (arg && arg[0]) {
|
||||
long now = jiffies();
|
||||
char uptm[42] = "N/A";
|
||||
char grbuf[128];
|
||||
char path[256];
|
||||
struct cg *cg;
|
||||
int exact = 0;
|
||||
char *group;
|
||||
|
||||
for (svc = client_svc_iterator(1); svc; svc = client_svc_iterator(0)) {
|
||||
svc_ident(svc, ident, sizeof(ident));
|
||||
if (string_match(ident, arg))
|
||||
num++;
|
||||
if (string_case_compare(ident, arg))
|
||||
exact++;
|
||||
}
|
||||
|
||||
if (num > 1 && !exact)
|
||||
break;
|
||||
|
||||
svc = client_svc_find(arg);
|
||||
if (!svc)
|
||||
return 255;
|
||||
@@ -768,9 +781,11 @@ static int show_status(char *arg)
|
||||
for (svc = client_svc_iterator(1); svc; svc = client_svc_iterator(0)) {
|
||||
char *lvls;
|
||||
|
||||
printf("%-*d ", pw, svc->pid);
|
||||
|
||||
svc_ident(svc, ident, sizeof(ident));
|
||||
if (num && !string_match(ident, arg))
|
||||
continue;
|
||||
|
||||
printf("%-*d ", pw, svc->pid);
|
||||
printf("%-*s %s ", iw, ident, status(svc, 0));
|
||||
|
||||
lvls = runlevel_string(runlevel, svc->runlevels);
|
||||
|
||||
Reference in New Issue
Block a user