mirror of
https://github.com/troglobit/finit.git
synced 2026-10-29 12:40:44 +00: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:
1 parent
b53f2f4a60
commit
df42c2f6fe
2 files changed
+23
-4
No files matched your search
+5
-1
@@ -132,7 +132,11 @@ Reload service by name (SIGHUP or restart)
|
|||||||
.It Nm Ar restart Cm NAME[:ID]
|
.It Nm Ar restart Cm NAME[:ID]
|
||||||
Restart (stop/start) service by name
|
Restart (stop/start) service by name
|
||||||
.It Nm Ar status Cm NAME[:ID]
|
.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
|
.It Nm Ar status
|
||||||
Show status of all services, default command
|
Show status of all services, default command
|
||||||
.It Nm Ar cgroup
|
.It Nm Ar cgroup
|
||||||
|
|||||||
+18
-3
@@ -703,18 +703,31 @@ static int show_status(char *arg)
|
|||||||
{
|
{
|
||||||
char ident[MAX_IDENT_LEN];
|
char ident[MAX_IDENT_LEN];
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
int num = 0;
|
||||||
svc_t *svc;
|
svc_t *svc;
|
||||||
|
|
||||||
runlevel = runlevel_get(NULL);
|
runlevel = runlevel_get(NULL);
|
||||||
|
|
||||||
if (arg && arg[0]) {
|
while (arg && arg[0]) {
|
||||||
long now = jiffies();
|
long now = jiffies();
|
||||||
char uptm[42] = "N/A";
|
char uptm[42] = "N/A";
|
||||||
char grbuf[128];
|
char grbuf[128];
|
||||||
char path[256];
|
char path[256];
|
||||||
struct cg *cg;
|
struct cg *cg;
|
||||||
|
int exact = 0;
|
||||||
char *group;
|
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);
|
svc = client_svc_find(arg);
|
||||||
if (!svc)
|
if (!svc)
|
||||||
return 255;
|
return 255;
|
||||||
@@ -768,9 +781,11 @@ static int show_status(char *arg)
|
|||||||
for (svc = client_svc_iterator(1); svc; svc = client_svc_iterator(0)) {
|
for (svc = client_svc_iterator(1); svc; svc = client_svc_iterator(0)) {
|
||||||
char *lvls;
|
char *lvls;
|
||||||
|
|
||||||
printf("%-*d ", pw, svc->pid);
|
|
||||||
|
|
||||||
svc_ident(svc, ident, sizeof(ident));
|
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));
|
printf("%-*s %s ", iw, ident, status(svc, 0));
|
||||||
|
|
||||||
lvls = runlevel_string(runlevel, svc->runlevels);
|
lvls = runlevel_string(runlevel, svc->runlevels);
|
||||||
|
|||||||
Reference in new issue
Block a user