mirror of
https://github.com/troglobit/finit.git
synced 2026-11-20 19:41:51 +00:00
service: spell the restart_sec: option restart-sec:
restart_sec: was the only setting in snake_case. Every other option
of the line-based format is in kebab-case, and so is the block format,
restart-sec = SEC.
Take restart-sec: and keep restart_sec: as an alias, so a .conf from
an older Finit loads as before:
service restart-sec:10 foo -- Foo daemon
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
6 files changed
+34
-11
No files matched your search
@@ -11,6 +11,9 @@ All relevant changes are documented in this file.
|
||||
- `shutdown` now takes a time, `now`, `+MIN`, or `HH:MM`, and a message.
|
||||
Finit warns logged-in users as the time approaches, refuses new logins
|
||||
from five minutes before, and `shutdown -c` cancels. Issue #149
|
||||
- The `restart_sec:` option of the line-based format is now spelled
|
||||
`restart-sec:`, kebab-case like every other setting. The old spelling
|
||||
is still accepted
|
||||
- Add `restart-max-sec`, a limit for the delay between restarts of a
|
||||
crashing service. When set, the delay doubles for each restart, from
|
||||
`restart-sec` up to the limit, and comes down again as the service keeps
|
||||
|
||||
@@ -63,7 +63,7 @@ Service options
|
||||
| `manual:yes` | `manual-start = true` |
|
||||
| `remain:yes` | `remain-after-exit = true` |
|
||||
| `restart:always` / `restart:NUM` | `restart = "always"` / `restart-max = NUM` |
|
||||
| `restart_sec:SEC` | `restart-sec = SEC` |
|
||||
| `restart-sec:SEC` | `restart-sec = SEC` |
|
||||
| `restart-max-sec:SEC` | `restart-max-sec = SEC` |
|
||||
| `norestart` | `restart = "never"` |
|
||||
| `respawn` | `respawn = true` |
|
||||
@@ -82,7 +82,8 @@ Service options
|
||||
| `if:svc` / `if:<cond>` | `if = "svc"` / `if = "cond"`, no angle brackets |
|
||||
| `tty:/dev/x` | `tty = "/dev/x"` |
|
||||
| `nowarn` | leading `-` on `command` or `envfile` |
|
||||
| `restarttmo:` | dropped, was already an alias for `restart_sec:` |
|
||||
| `restart_sec:` | old spelling of `restart-sec:`, still accepted |
|
||||
| `restarttmo:` | dropped, was already an alias for `restart-sec:` |
|
||||
|
||||
Repeated stanzas
|
||||
----------------
|
||||
|
||||
+7
-5
@@ -379,18 +379,20 @@ marked
|
||||
.Em crashed
|
||||
and must be restarted manually with
|
||||
.Xr initctl 8 .
|
||||
.It Cm restart_sec:SEC
|
||||
.It Cm restart-sec:SEC
|
||||
number of seconds before Finit tries to restart
|
||||
a crashing service, default: 2 seconds for the first five retries,
|
||||
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. The old spelling,
|
||||
.Cm restart_sec:SEC ,
|
||||
is still accepted
|
||||
.It Cm restart-max-sec:SEC
|
||||
replaces that back-off with a delay that doubles for each restart, from
|
||||
.Cm restart_sec
|
||||
.Cm restart-sec
|
||||
up to this limit, e.g. 10, 20, 40, and so on up to 300 seconds with
|
||||
.Cm restart_sec:10 restart-max-sec:300 .
|
||||
.Cm restart-sec:10 restart-max-sec:300 .
|
||||
Without
|
||||
.Cm restart_sec
|
||||
.Cm restart-sec
|
||||
the first restart is at once, then after 2, 4, 8 seconds. The delay
|
||||
comes down again as the service keeps running
|
||||
.It Cm restart:always
|
||||
|
||||
+1
-1
@@ -1668,7 +1668,7 @@ static void svc_translate(cfg_t *sec, int type, struct rlimit rlimit[], char *fi
|
||||
}
|
||||
|
||||
if (sec_getint(sec, "restart-sec", NULL, &num))
|
||||
addtok(line, sizeof(line), "restart_sec:%ld", num);
|
||||
addtok(line, sizeof(line), "restart-sec:%ld", num);
|
||||
if (sec_getint(sec, "restart-max-sec", NULL, &num))
|
||||
addtok(line, sizeof(line), "restart-max-sec:%ld", num);
|
||||
|
||||
|
||||
+3
-3
@@ -2396,9 +2396,9 @@ svc_t *service_register_desc(int type, char *cfg, const char *desc,
|
||||
else
|
||||
restart_max = atoi(arg);
|
||||
}
|
||||
else if (MATCH_CMD(cmd, "restarttmo:", arg)) /* compat alias */
|
||||
restart_tmo = atoi(arg) * 1000;
|
||||
else if (MATCH_CMD(cmd, "restart_sec:", arg))
|
||||
else if (MATCH_CMD(cmd, "restart-sec:", arg) ||
|
||||
MATCH_CMD(cmd, "restart_sec:", arg) || /* compat alias */
|
||||
MATCH_CMD(cmd, "restarttmo:", arg)) /* compat alias */
|
||||
restart_tmo = atoi(arg) * 1000;
|
||||
else if (MATCH_CMD(cmd, "restart-max-sec:", arg)) {
|
||||
const char *errstr;
|
||||
|
||||
@@ -32,6 +32,16 @@ CONF
|
||||
run "initctl reload"
|
||||
}
|
||||
|
||||
# Same, with the line-based format, options in $1
|
||||
crash_line()
|
||||
{
|
||||
run "rm -f $FINIT_CONF"
|
||||
run "initctl reload"
|
||||
run "rm -f $STARTS"
|
||||
run "echo 'service $1 crash.sh -- Crashing' > $FINIT_CONF"
|
||||
run "initctl reload"
|
||||
}
|
||||
|
||||
test_teardown()
|
||||
{
|
||||
say "Running test teardown."
|
||||
@@ -67,3 +77,10 @@ assert_delay 4 5 4 5
|
||||
|
||||
say 'The restart counter stops where the delay peaks'
|
||||
assert "Restart counter is 2" "$(texec initctl status crash | awk '/Restarts/{ print $4 }')" = "(2/-1)"
|
||||
|
||||
sep
|
||||
say 'restart-sec in the line-based format, and its old spelling'
|
||||
crash_line 'restart:always restart-sec:3'
|
||||
assert_delay 1 2 3 4
|
||||
crash_line 'restart:always restart_sec:3'
|
||||
assert_delay 1 2 3 4
|
||||
Reference in new issue
Block a user