Commit Graph
3 Commits
Author SHA1 Message Date
Joachim Wiberg aae640b8f3 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>
2026-11-19 20:39:42 +01:00
Joachim Wiberg 62bd5f4892 service: add restart-max-sec, a limit for the restart back-off
The delay between restarts of a crashing service is fixed: two
seconds, then five, or restart-sec if that is longer.  A service that
should be retried quickly at first and then less and less often, e.g.
a modem dialer, cannot be set up.

Add restart-max-sec, in the block format and as the restart-max-sec:
token:

    service dialer {
        restart         = "always"
        restart-sec     = 10
        restart-max-sec = 300
        command         = "dialer"
    }

When set, the delay doubles for each restart, from restart-sec up to
the limit: 10, 20, 40, 80, 160, 300.  Without restart-sec the first
restart is at once, then after 2, 4, 8 seconds.  The delay follows the
restart counter, so it comes down again as the counter ages.  With
restart always the counter stops where the delay peaks.

Fixes #306

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2026-11-19 20:39:42 +01:00
Joachim Wiberg 4e1b0d4fbe service: start restart always at two seconds between restarts
A crashing service with restart always waited five seconds before
every restart.  It should wait two seconds for the first five, like a
service with the default restart-max:

    service foo {
        restart = "always"
        command = "foo"
    }

The back-off starts after half of restart-max attempts.  For restart
always restart-max is -1, so half of it was zero and the back-off
began with the first restart.  Use the default restart-max instead.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2026-11-19 20:39:40 +01:00