Subject: Re: [bug#32128] [PATCH 0/2] Support custom actions for Shepherd services

From: [email-masked] (Ludovic Courtès)
Date: Fri, 13 Jul 2018 00:40:18 +0200

Hello Clément,

Clément Lassieur <[email-masked]> skribis:

> Ludovic Courtès <[email-masked]> writes:
>
>> Hello Guix!
>>
>> This is a long-awaited feature—nothing fancy, but it can certainly be
>> useful as illustrated by the ‘herd schedule mcron’ example below.
>>
>> I suppose we can add actions for hot-swapping and reconfiguration of
>> services that support it, such as nginx: <https://bugs.gnu.org/26830>.
>
> This is fantastic!  Thank you :-)  And it looks good to me.

Thanks!  I’ve pushed it.

> A few notes though (more about the Shepherd):
>
> - It would be great to be able to use actions even when services are not
>   started.  In the case of the "mcron" service, for example, it makes
>   sense: one may not want to risk spawning a program while wanting to
>   debug the schedule.

Indeed, I think this restriction should be waived, and this comment from
ca. 2003 in shepherd/service.scm suggests it’s unfounded:

    ;; Calling default-action will be allowed even when the service is
    ;; not running, as it provides generally useful functionality and
    ;; information.
    ;; FIXME: Why should the user-implementations not be allowed to be
    ;; called this way?

Done in Shepherd commit 5ab8cbc9bcfce586a5389ad95a65f011d02bd289.

> - It seems that sometimes the SIGCHLD handler is invoked, when the
>   'running' field is not yet set.  Should CALL-WITH-BLOCKED-ASYNCS be
>   used?

As discussed on IRC, the error we were getting when doing things like
“herd schedule mcron 50” (“waitpid: No child processes”), came from the
fact that ‘close-pipe’ invokes ‘waitpid’, but there’s a race with the
Shepherd’s SIGCHLD handler, which might get to call ‘waitpid’ earlier.

I’ve adjusted to code to protect against it but without blocking asyncs,
which seems safer.

Thank you!

Ludo’.