aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2018-11-30 18:07:16 -0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2018-12-02 18:33:25 -0600
commitebf79db79eaa2df0ceb62b4edbef94e68a28b612 (patch)
treed5c8ebfdca7edae129bf4d0daa9d530a8dcf455d /src
parent1b5a3b4ef4b2c3e20cfe4a71cf38c63279ed42d2 (diff)
supervise-daemon: mark a service failed if it respawns too many times
Diffstat (limited to 'src')
-rw-r--r--src/rc/supervise-daemon.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index d93d31f8..c2082100 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -446,6 +446,7 @@ static void supervisor(char *exec, char **argv)
char buf[2048];
char cmd[2048];
int count;
+ int failing;
int health_status;
int healthcheck_respawn;
int i;
@@ -498,6 +499,7 @@ static void supervisor(char *exec, char **argv)
else if (healthchecktimer)
alarm(healthchecktimer);
fifo_fd = open(fifopath, O_RDONLY |O_NONBLOCK);
+ failing = 0;
while (!exiting) {
healthcheck_respawn = 0;
wait_pid = waitpid(child_pid, &i, WNOHANG);
@@ -576,6 +578,7 @@ static void supervisor(char *exec, char **argv)
syslog(LOG_WARNING, "respawned \"%s\" too many times, exiting",
exec);
exiting = 1;
+ failing = 1;
continue;
}
ts.tv_sec = respawn_delay;
@@ -602,16 +605,18 @@ static void supervisor(char *exec, char **argv)
}
}
- if (pidfile && exists(pidfile))
- unlink(pidfile);
- if (fifopath && exists(fifopath))
- unlink(fifopath);
if (svcname) {
rc_service_daemon_set(svcname, exec, (const char *const *)argv,
pidfile, false);
- rc_service_mark(svcname, RC_SERVICE_STOPPED);
rc_service_value_set(svcname, "child_pid", NULL);
+ rc_service_mark(svcname, RC_SERVICE_STOPPED);
+ if (failing)
+ rc_service_mark(svcname, RC_SERVICE_FAILED);
}
+ if (pidfile && exists(pidfile))
+ unlink(pidfile);
+ if (fifopath && exists(fifopath))
+ unlink(fifopath);
exit(EXIT_SUCCESS);
}