mirror of
https://github.com/troglobit/finit.git
synced 2026-11-20 19:41:51 +00:00
service: save the configured restart delay when registering
The configured restart delay was saved at the first restart, when the restart counter went from zero to one, and restored when a restart succeeded. The counter ages back to zero while the service runs. If it did so right after a restart and the service crashed again, the back-off delay was saved over the configured one. From then on the first restart after a crash waited two or five seconds, until the next reload. Save it once, when the service is registered. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
2 files changed
+3
-2
No files matched your search
@@ -188,6 +188,8 @@ All relevant changes are documented in this file.
|
|||||||
- Fix a command whose name starts like a service option, e.g. `logger` or
|
- Fix a command whose name starts like a service option, e.g. `logger` or
|
||||||
`pidof`. It was taken as the `log` or `pid` option and the next argument
|
`pidof`. It was taken as the `log` or `pid` option and the next argument
|
||||||
ran as the command, which also broke the `logger` example in finit.conf(5)
|
ran as the command, which also broke the `logger` example in finit.conf(5)
|
||||||
|
- Fix the delay before the first restart of a crashing service, it could
|
||||||
|
grow to the back-off delay and stay there until the next reload
|
||||||
- Fix the restart counter of a service with `restart = "always"`, nothing
|
- Fix the restart counter of a service with `restart = "always"`, nothing
|
||||||
stopped it and it overflowed after 127 restarts, 255 on Arm. It now
|
stopped it and it overflowed after 127 restarts, 255 on Arm. It now
|
||||||
stops at 10, where the back-off has long since peaked, and ages from
|
stops at 10, where the back-off has long since peaked, and ages from
|
||||||
|
|||||||
+1
-2
@@ -2776,6 +2776,7 @@ svc_t *service_register_desc(int type, char *cfg, const char *desc,
|
|||||||
/* TTYs need a longer default to throttle errors (e.g., missing device) */
|
/* TTYs need a longer default to throttle errors (e.g., missing device) */
|
||||||
if (svc_is_tty(svc) && svc->restart_tmo == 0)
|
if (svc_is_tty(svc) && svc->restart_tmo == 0)
|
||||||
svc->restart_tmo = 2000;
|
svc->restart_tmo = 2000;
|
||||||
|
svc->restart_saved = svc->restart_tmo;
|
||||||
|
|
||||||
/* Set configured limits */
|
/* Set configured limits */
|
||||||
memcpy(svc->rlimit, rlimit, sizeof(svc->rlimit));
|
memcpy(svc->rlimit, rlimit, sizeof(svc->rlimit));
|
||||||
@@ -3334,8 +3335,6 @@ static void service_retry(svc_t *svc)
|
|||||||
restart_cnt_inc(svc);
|
restart_cnt_inc(svc);
|
||||||
|
|
||||||
dbg("%s crashed, trying to start it again, attempt %d", svc_ident(svc, NULL, 0), *restart_cnt);
|
dbg("%s crashed, trying to start it again, attempt %d", svc_ident(svc, NULL, 0), *restart_cnt);
|
||||||
if ((*restart_cnt) == 1)
|
|
||||||
svc->restart_saved = svc->restart_tmo;
|
|
||||||
/* Wait 2s for the first half of the attempts, then back off to 5s */
|
/* Wait 2s for the first half of the attempts, then back off to 5s */
|
||||||
half = (svc->restart_max == -1 ? SVC_RESPAWN_MAX : svc->restart_max) / 2;
|
half = (svc->restart_max == -1 ? SVC_RESPAWN_MAX : svc->restart_max) / 2;
|
||||||
timeout = *restart_cnt <= half ? 2000 : 5000;
|
timeout = *restart_cnt <= half ? 2000 : 5000;
|
||||||
|
|||||||
Reference in new issue
Block a user