[2019-11-06 13:45] Lorenzo Puliti <lorenzo.r...@gmail.com>
> Package: runit
> Version: 2.1.2-35
> Followup-For: Bug #943397
>
> I'm attaching two patches for review;

> one thing that I'm still not sure about is the exit code range.  $1 in
> the finish file can be run's exit code or the daemon's exit code.  I'm
> using the wierd range 160-170 but is still possible that the exit code
> is overlapped with the one of some daemons, for example see smartd(8)
> 'EXIT STATUS' section.  Do you have a better range to suggest?

I do not have better plan. And since you already used these values in
patches, let us stick to them.

> +NAME=$(pwd | cut -f4 -d"/")

Maybe NAME=${PWD##*/}? Also, `set -e`, please.

> +trap 'if [ "$VERBOSE" = 1 ]; then echo "runsv: $NAME stopped"; fi' EXIT

I'd say this is simplier:

        if [ "${VERBOSE:-0}" != 0 ] ; then
                trap "echo runsv: $NAME stopped" EXIT
        fi

> +case $1 in
> +     -1)
> +             echo "runsv: ERROR $1 in $NAME: unexpected error or wrong sh 
> syntax"
> +             # no need to sv d service here, runsv will stop trying after 
> the first attempt to start
> +             ;;

Are you sure about "wrong sh syntax" part? As far as I know, shell exit
with $? = 2 in case of wrong syntax, and "runsv" has no means to
distinguish it from plain "exit 2". Also, runsv(1) mentions "didn't exit
correctly", which I believe means signal.

> +     161)

Please, follow same style as in invoke-run. Unmatched brackets drive
editors crazy.

> +++ b/debian/runit.install
> @@ -23,3 +23,4 @@ debian/contrib/runlevel             /lib/runit
>  debian/sulogin/run                  /etc/runit/runsvdir/single/sulogin
>  debian/contrib/lib/async-timeout    /lib/runit
>  debian/contrib/lib/run_sysv_scripts /lib/runit
> +debian/contrib/lib/finish-default /lib/runit

!sort, please.

> part 3     text/plain                3239
> From 642ffb914b6e7d67c723f7e620f3b9a404d7572e Mon Sep 17 00:00:00 2001
> From: Lorenzo Puliti <lorenzo.r...@gmail.com>
> Date: Tue, 5 Nov 2019 23:49:58 +0100
> Subject: [PATCH 2/2] Update invoke-run manpage for finish-default
>
> Update invoke-run manpage to account for finish-default file and
> special error codes.
> [...]
> +.IP "" 2
> +.B runsv: foo binary not installed
> +.PP
> +.IP "" 4
> +this happens when the
> +.I foo
> +binary has been removed, but not purged.

s/binary/package, containing binary/ or something like this. Binaries
(e.g ELF executable files) can't be removed-not-purged, binary packages
are.

> +.B runsv: ERROR -1 in foo: unexpected error or wrong sh syntax
> +.PP
> +.IP "" 4
> +this message comes from the finish file, but the exit code comes from
> +.BR runsv (8)
> +and is documented in its manpage.

Ditto on "wrong sh syntax"

> +.B runsv: ERROR 161 in foo: disabled by local settings
> +.PP
> +.IP "" 4
> +Some service specific setting prevent
> +.I foo
> +from starting; it's likely something in
> +.BI /etc/default/foo

Is it really ERROR? Maybe change it to "NOTE" or something like this?
By the way (and I agree), Policy deprecated following pattern:

        $ grep DISABLED /etc/default/foo
        DISABLED=1


> +.PP
> +.IP "" 2
> +.B runsv: ERROR 162 in foo: configtest or early setup failed
> +.PP
> +.IP "" 4
> +A configuration file of
> +.I foo
> +is malformed and the configtest failed;
> +.I foo
> +log may contain additional info from the test itself.
> +Otherwise 

I think "alternatively" is more correct word. Take with grain of salt, I
am not native speaker.

> the runscript has failed to do some setup that is essential to the
> +.I foo
> +service.
> +.PP
> +.IP "" 2
> +.B runsv: ERROR 170 in foo: a runtime hard dependency is missing
> +.PP
> +.IP "" 4
> +A dependency failed the check and can't be bring up; a list of dependencies 
> of
> +.I foo
> +can be extracted with the following command
> +.PP
> +.IP "" 6
> +.EX
> +grep 'exit 170' /etc/sv/foo/run | cut -d ' ' -f3

I'd not recommend this because of following:

        if full_moon ; then
                set -- dep1 dep2
        else
                set -- dep3 dep4
        fi
        sv up "$@" || exit 170


> +.SH FINISH FILE AND FINISH-DEFAULT
> +Since version 2.1.2-36 the Debian runit package ships a
> +.BI /lib/runit/finish-default
> +file that contains code that can be shared across different services.
> +This file can be sourced inside the regular finish file of a service,
> +like the following example

Wonderful.
-- 
Note, that I send and fetch email in batch, once in a few days.
Please, mention in body of your reply when you add or remove recepients.

Reply via email to