Skip to content

Commit 2c95f09

Browse files
committed
Sync documentation and manual page
Signed-off-by: Joachim Wiberg <[email protected]>
1 parent b75b107 commit 2c95f09

File tree

2 files changed

+42
-27
lines changed

2 files changed

+42
-27
lines changed

doc/config.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,9 +919,10 @@ argument, but get a set of environment variables:
919919
* `SERVICE_ID=1`
920920

921921
The `post:script` is called with an additional set of environment
922-
variables:
922+
variables. Yes, the text is correct, the naming was an accident:
923923

924-
- `EXIT_CODE=[exited,signal]`: set to one of `exited` or `signal`
924+
- `EXIT_CODE=[exited,signal,crashed]`: normal exit, signaled, or
925+
crashed
925926
- `EXIT_STATUS=[num,SIGNAME]`: set to one of exit status code from
926927
the program, if it exited normally, or the signal name (`HUP`,
927928
`TERM`, etc.) if it exited due to signal

man/finit.conf.5

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,13 @@ task [s] echo "foo" | cat >/tmp/bar
175175
.Ed
176176
.It Cm sysv Oo LVLS Oc Ao COND Ac Ar /path/to/script ARGS Op -- Optional description
177177
Similar to
178-
.Cm task
178+
.Cm service
179179
is the
180180
.Cm sysv
181181
stanza, which can be used to call SysV style start/stop scripts. The
182-
primary intention for this command is to be able to re-use much of
183-
existing setup and init scripts in Linux distributions.
184-
.Pp
182+
primary intention for this command is to be able to re-use traditional
183+
SysV init scripts in Linux distributions.
184+
.Pp
185185
When entering an allowed runlevel, Finit calls
186186
.Cm init-script start ,
187187
when entering a disallowed runlevel, Finit calls
@@ -434,30 +434,42 @@ e.g.,
434434
.Cm kill:10
435435
to wait 10 seconds before sending SIGKILL.
436436
.Pp
437-
Services support the
438-
.Cm pre:script
439-
and
440-
.Cm post:script
441-
command actions as well. These run as the same
437+
Services, including the
438+
.Cm sysv
439+
variant, support pre/post/ready and cleanup scripts:
440+
.Bl -tag -width 1n
441+
.It Cm pre:[0-3600,]script
442+
called before the sysv/service is stated
443+
.It Cm post:[0-3600,]script
444+
called after the sysv/service has stopped
445+
.It Cm ready:[0-3600,]script
446+
called when the sysv/service is ready
447+
.It Cm cleanup:[0-3600,]script
448+
called when run/task/sysv/service is removed
449+
.El
450+
.Pp
451+
The optional number (0-3600) is the timeout before Finit kills the
452+
script, it defaults to the kill delay value and can be disabled by
453+
setting it to zero. These scripts run as the same
442454
.Cm @USER:GROUP
443455
as the service itself, with any
444456
.Cm env:file
445457
sourced. The scripts must use an absolute path, but are executed from
446458
the
447459
.Cm $HOME
448-
of the given user. The scripts are not called with any argument
449-
(currently), but both get the
450-
.Cm SERVICE_IDENT=foo
451-
environment variable set. Here
452-
.Cm foo
453-
denotes the identity of the service, which if there are multiple
454-
services named
455-
.Cm foo ,
456-
may be
457-
.Cm foo:1 ,
458-
or any unique identifier specified in the .conf file. The
460+
of the given user. The scripts are not called with any argument, but
461+
both get a set of environment variables:
462+
.Pp
463+
.Bl -tag -width 1n -compact
464+
.It Cm SERVICE_IDENT=foo:1
465+
.It Cm SERVICE_NAME=foo
466+
.It Cm SERVICE_ID=1
467+
.El
468+
.Pp
469+
The
459470
.Cm post:script
460-
is called with an additional set of environment variables:
471+
is called with an additional set of environment variables, and yes the
472+
naming looks like it should be swapped:
461473
.Bl -tag -offset indent -width 1n
462474
.It Cm EXIT_CODE=[exited,signal,crashed]
463475
set to one of
@@ -471,10 +483,12 @@ set to one of exit status code from the program, if it exited normally,
471483
or the signal name (HUP, TERM, etc.) if it exited due to signal
472484
.El
473485
.Pp
474-
The scripts have a default execution time of 3 seconds before they are
475-
SIGKILLed, this can be adjusted using the
476-
.Cm kill:SEC
477-
modifier syntax.
486+
When a run/task/sys/service is removed (disable + reload) it is first
487+
stopped and then removed from the runlevel. The
488+
.Cm post:script
489+
always runs when the process has stopped, and the
490+
.Cm cleanup:script
491+
runs when the the stanza has been removed from the runlevel.
478492
.It Cm runparts Aq DIR
479493
Call
480494
.Xr run-parts 8

0 commit comments

Comments
 (0)