implement "unsupervised" status
The unsupervised status is to be used when a supervisor of a supervised service dies but leaves the service daemon itself running.
This commit is contained in:
parent
667a09983c
commit
82da844b42
@ -58,23 +58,12 @@ supervise_stop()
|
|||||||
|
|
||||||
_check_supervised()
|
_check_supervised()
|
||||||
{
|
{
|
||||||
[ "$RC_UNAME" != Linux ] && return 0
|
local child_pid start_time
|
||||||
local child_pid="$(service_get_value "child_pid")"
|
child_pid="$(service_get_value "child_pid")"
|
||||||
local pid="$(cat ${pidfile})"
|
start_time="$(service_get_value "start_time")"
|
||||||
if [ -n "${child_pid}" ]; then
|
if [ -n "${child_pid}" ] && [ -n "${start_time}" ]; then
|
||||||
if ! [ -e "/proc/${pid}" ] && [ -e "/proc/${child_pid}" ]; then
|
|
||||||
if [ -e "/proc/self/ns/pid" ] && [ -e "/proc/${child_pid}/ns/pid" ]; then
|
|
||||||
local n1 n2
|
|
||||||
n1=$(readlink "/proc/self/ns/pid")
|
|
||||||
n2=$(readlink "/proc/${child_pid}/ns/pid")
|
|
||||||
if [ "${n1}" = "${n2}" ]; then
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +128,8 @@ print_service(const char *service)
|
|||||||
{
|
{
|
||||||
char status[60];
|
char status[60];
|
||||||
char uptime [40];
|
char uptime [40];
|
||||||
|
char *child_pid = NULL;
|
||||||
|
char *start_time = NULL;
|
||||||
int cols = printf(" %s", service);
|
int cols = printf(" %s", service);
|
||||||
const char *c = ecolor(ECOLOR_GOOD);
|
const char *c = ecolor(ECOLOR_GOOD);
|
||||||
RC_SERVICE state = rc_service_state(service);
|
RC_SERVICE state = rc_service_state(service);
|
||||||
@ -147,7 +149,14 @@ print_service(const char *service)
|
|||||||
rc_service_daemons_crashed(service) &&
|
rc_service_daemons_crashed(service) &&
|
||||||
errno != EACCES)
|
errno != EACCES)
|
||||||
{
|
{
|
||||||
|
child_pid = rc_service_value_get(service, "child_pid");
|
||||||
|
start_time = rc_service_value_get(service, "start_time");
|
||||||
|
if (start_time && child_pid)
|
||||||
|
snprintf(status, sizeof(status), " unsupervised ");
|
||||||
|
else
|
||||||
snprintf(status, sizeof(status), " crashed ");
|
snprintf(status, sizeof(status), " crashed ");
|
||||||
|
free(child_pid);
|
||||||
|
free(start_time);
|
||||||
} else {
|
} else {
|
||||||
get_uptime(service, uptime, 40);
|
get_uptime(service, uptime, 40);
|
||||||
snprintf(status, sizeof(status), " started %s", uptime);
|
snprintf(status, sizeof(status), " started %s", uptime);
|
||||||
|
Loading…
Reference in New Issue
Block a user