diff options
author | David Oberhollenzer <goliath@infraroot.at> | 2019-03-18 18:38:27 +0100 |
---|---|---|
committer | David Oberhollenzer <goliath@infraroot.at> | 2019-03-18 18:47:20 +0100 |
commit | a9602ad6e018afd7621052e1263d3cae0e6da5f3 (patch) | |
tree | 55f702e36171f58112b9fc05c1d9d393e643bddf /cmd/service | |
parent | 3f40c4d3ed5d13e98a92773a475883237c3b549b (diff) |
Cleanup status reporting
- mimic format of initd
- skip formatting if not a tty
- distinguish exited because failed vs exited because done
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
Diffstat (limited to 'cmd/service')
-rw-r--r-- | cmd/service/status.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/cmd/service/status.c b/cmd/service/status.c index c8e87c4..3be2f3e 100644 --- a/cmd/service/status.c +++ b/cmd/service/status.c @@ -53,31 +53,35 @@ static int cmd_status(int argc, char **argv) switch (resp.state) { case ESS_RUNNING: if (!is_tty) { - state = "Running"; + state = "UP"; break; } - state = "\033[22;32mRunning\033[0m"; + state = "\033[22;32m UP \033[0m"; break; case ESS_ENQUEUED: - state = " Queue "; + state = "SCHED"; break; - case ESS_EXITED: + case ESS_FAILED: if (!is_tty) { - state = "Exited "; + state = "FAIL"; break; } - if (resp.exit_status == EXIT_SUCCESS) { - state = "\033[22;33mExited \033[0m"; - } else { - state = "\033[22;31mExited \033[0m"; + state = "\033[22;31mFAIL\033[0m"; + break; + case ESS_DONE: + if (!is_tty) { + state = "DONE"; + break; } + + state = "\033[22;33mDONE\033[0m"; break; default: if (!is_tty) { - state = "Unknown"; + state = "UNKNOWN"; break; } - state = "\033[22;31mUnknown\033[0m"; + state = "\033[22;31mUNKNOWN\033[0m"; break; } @@ -98,8 +102,8 @@ static command_t status = { .usage = "", .s_desc = "report the status of the currently enabled services", .l_desc = "Gathers a list of all currently running services and the " - "state that they are in (currently running, exited, wating " - "to get scheduled).", + "state that they are in (currently running, done, failed, " + "wating to get scheduled).", .run_cmd = cmd_status, }; |