mirror of
https://github.com/troglobit/finit.git
synced 2026-10-22 11:36:07 +00:00
Fix #279: allow restart:always, restart:-1, of crashing services
This change allows endless restarts, similar to `respawn` but honors `restart_sec`. There is no upper limit on the number of times Finit tries to restart a crashing service. Same as `restart:-1` Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
f50b5a4ac6
commit
f8dfcdf024
4 files changed
+10
-2
No files matched your search
@@ -450,6 +450,8 @@ configurable with the following options:
|
|||||||
a crashing service, default: 2 seconds for the first five retries,
|
a crashing service, default: 2 seconds for the first five retries,
|
||||||
then back-off to 5 seconds. The maximum of this configured value
|
then back-off to 5 seconds. The maximum of this configured value
|
||||||
and the above (2 and 5) will be used
|
and the above (2 and 5) will be used
|
||||||
|
* `restart:always` -- no upper limit on the number of times Finit
|
||||||
|
tries to restart a crashing service. Same as `restart:-1`
|
||||||
* `norestart` -- dont restart on failures, same as `restart:0`
|
* `norestart` -- dont restart on failures, same as `restart:0`
|
||||||
* `respawn` -- bypasses the `restart` mechanism completely, allows
|
* `respawn` -- bypasses the `restart` mechanism completely, allows
|
||||||
endless restarts. Useful in many use-cases, but not what `service`
|
endless restarts. Useful in many use-cases, but not what `service`
|
||||||
|
|||||||
@@ -304,6 +304,10 @@ number of seconds before Finit tries to restart
|
|||||||
a crashing service, default: 2 seconds for the first five retries,
|
a crashing service, default: 2 seconds for the first five retries,
|
||||||
then back-off to 5 seconds. The maximum of this configured value
|
then back-off to 5 seconds. The maximum of this configured value
|
||||||
and the above (2 and 5) will be used
|
and the above (2 and 5) will be used
|
||||||
|
.It Cm restart:always
|
||||||
|
no upper limit on the number of times Finit tries to restart a crashing
|
||||||
|
service. Same as
|
||||||
|
.Cm restart:-1
|
||||||
.It Cm norestart
|
.It Cm norestart
|
||||||
dont restart on failures, same as
|
dont restart on failures, same as
|
||||||
.Cm restart:0
|
.Cm restart:0
|
||||||
|
|||||||
+3
-1
@@ -1274,6 +1274,8 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
|
|||||||
forking = 1;
|
forking = 1;
|
||||||
else if (!strncasecmp(cmd, "manual:yes", 10))
|
else if (!strncasecmp(cmd, "manual:yes", 10))
|
||||||
manual = 1;
|
manual = 1;
|
||||||
|
else if (!strncasecmp(cmd, "restart:always", 14))
|
||||||
|
restart_max = -1;
|
||||||
else if (!strncasecmp(cmd, "restart:", 8))
|
else if (!strncasecmp(cmd, "restart:", 8))
|
||||||
restart_max = atoi(&cmd[8]);
|
restart_max = atoi(&cmd[8]);
|
||||||
else if (!strncasecmp(cmd, "restarttmo:", 11)) /* compat alias */
|
else if (!strncasecmp(cmd, "restarttmo:", 11)) /* compat alias */
|
||||||
@@ -1759,7 +1761,7 @@ static void service_retry(svc_t *svc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Peak instability index */
|
/* Peak instability index */
|
||||||
if (*restart_cnt >= svc->restart_max) {
|
if (svc->restart_max != -1 && *restart_cnt >= svc->restart_max) {
|
||||||
logit(LOG_CONSOLE | LOG_WARNING, "Service %s keeps crashing, not restarting.",
|
logit(LOG_CONSOLE | LOG_WARNING, "Service %s keeps crashing, not restarting.",
|
||||||
svc_ident(svc, NULL, 0));
|
svc_ident(svc, NULL, 0));
|
||||||
svc_crashing(svc);
|
svc_crashing(svc);
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ typedef struct svc {
|
|||||||
/* Counters */
|
/* Counters */
|
||||||
char once; /* run/task, (at least) once per runlevel */
|
char once; /* run/task, (at least) once per runlevel */
|
||||||
unsigned int restart_tot; /* Total restarts ever, summarized, including `initctl restart` */
|
unsigned int restart_tot; /* Total restarts ever, summarized, including `initctl restart` */
|
||||||
unsigned char restart_max; /* Maximum number of restarts allowed */
|
int restart_max; /* Maximum number of restarts allowed */
|
||||||
int restart_tmo; /* Time required for the service to start. */
|
int restart_tmo; /* Time required for the service to start. */
|
||||||
unsigned char oncrash_action; /* Action to perform in crashed state. */
|
unsigned char oncrash_action; /* Action to perform in crashed state. */
|
||||||
char respawn; /* ttys, or services with `respawn`, never increment restart_cnt */
|
char respawn; /* ttys, or services with `respawn`, never increment restart_cnt */
|
||||||
|
|||||||
Reference in new issue
Block a user