From unknown Wed Jun 18 00:13:29 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#32128 <32128@debbugs.gnu.org> To: bug#32128 <32128@debbugs.gnu.org> Subject: Status: [PATCH 0/2] Support custom actions for Shepherd services Reply-To: bug#32128 <32128@debbugs.gnu.org> Date: Wed, 18 Jun 2025 07:13:29 +0000 retitle 32128 [PATCH 0/2] Support custom actions for Shepherd services reassign 32128 guix-patches submitter 32128 Ludovic Court=C3=A8s severity 32128 normal tag 32128 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 11 17:47:47 2018 Received: (at submit) by debbugs.gnu.org; 11 Jul 2018 21:47:47 +0000 Received: from localhost ([127.0.0.1]:55996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fdMxd-0004xM-Kf for submit@debbugs.gnu.org; Wed, 11 Jul 2018 17:47:47 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56363) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fdMxb-0004x9-9I for submit@debbugs.gnu.org; Wed, 11 Jul 2018 17:47:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdMxV-00011C-D6 for submit@debbugs.gnu.org; Wed, 11 Jul 2018 17:47:38 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:51952) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fdMxV-000116-9P for submit@debbugs.gnu.org; Wed, 11 Jul 2018 17:47:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdMxU-00038M-0G for guix-patches@gnu.org; Wed, 11 Jul 2018 17:47:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdMxT-0000yl-3B for guix-patches@gnu.org; Wed, 11 Jul 2018 17:47:36 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:58955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdMxQ-0000uu-E5; Wed, 11 Jul 2018 17:47:32 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=59538 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fdMxQ-0000dC-1K; Wed, 11 Jul 2018 17:47:32 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-patches@gnu.org Subject: [PATCH 0/2] Support custom actions for Shepherd services Date: Wed, 11 Jul 2018 23:47:17 +0200 Message-Id: <20180711214717.29955-1-ludo@gnu.org> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) 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: . Feedback welcome! Ludo’. Ludovic Courtès (2): services: shepherd: Support custom actions. services: mcron: Add 'schedule' action. doc/guix.texi | 74 +++++++++++++++++++++++++++++++++++++++ gnu/services/herd.scm | 3 ++ gnu/services/mcron.scm | 67 ++++++++++++++++++++++++++--------- gnu/services/shepherd.scm | 23 +++++++++++- gnu/tests/base.scm | 7 ++++ 5 files changed, 156 insertions(+), 18 deletions(-) -- 2.18.0 From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 11 17:55:24 2018 Received: (at 32128) by debbugs.gnu.org; 11 Jul 2018 21:55:24 +0000 Received: from localhost ([127.0.0.1]:56009 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fdN51-0005AX-Tk for submit@debbugs.gnu.org; Wed, 11 Jul 2018 17:55:24 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57691) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fdN51-0005AG-2L for 32128@debbugs.gnu.org; Wed, 11 Jul 2018 17:55:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdN4u-00040b-J7 for 32128@debbugs.gnu.org; Wed, 11 Jul 2018 17:55:17 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:59095) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdN4r-0003xP-WF; Wed, 11 Jul 2018 17:55:14 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=59732 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fdN4r-00012Z-Jn; Wed, 11 Jul 2018 17:55:13 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 32128@debbugs.gnu.org Subject: [PATCH 1/2] services: shepherd: Support custom actions. Date: Wed, 11 Jul 2018 23:55:03 +0200 Message-Id: <20180711215504.30221-1-ludo@gnu.org> X-Mailer: git-send-email 2.18.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 32128 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) * gnu/services/shepherd.scm ()[actions]: New field. (): New record type. (shepherd-service-file): Pass #:actions to 'make'. * doc/guix.texi (Shepherd Services): Document custom actions. --- doc/guix.texi | 59 +++++++++++++++++++++++++++++++++++++++ gnu/services/shepherd.scm | 23 ++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 8026bea35..0a6b2244d 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -21963,6 +21963,17 @@ Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as G-expressions that get expanded in the Shepherd configuration file (@pxref{G-Expressions}). +@item @code{actions} (default: @code{'()}) +@cindex actions, of Shepherd services +This is a list of @code{shepherd-action} objects (see below) defining +@dfn{actions} supported by the service, in addition to the standard +@code{start} and @code{stop} actions. Actions listed here become available as +@command{herd} sub-commands: + +@example +herd @var{action} @var{service} [@var{arguments}@dots{}] +@end example + @item @code{documentation} A documentation string, as shown when running: @@ -21980,6 +21991,54 @@ This is the list of modules that must be in scope when @code{start} and @end table @end deftp +@deftp {Data Type} shepherd-action +This is the data type that defines additional actions implemented by a +Shepherd service (see above). + +@table @code +@item name +Symbol naming the action. + +@item documentation +This is a documentation string for the action. It can be viewed by running: + +@example +herd doc @var{service} action @var{action} +@end example + +@item procedure +This should be a gexp that evaluates to a procedure of at least one argument, +which is the ``running value'' of the service (@pxref{Slots of services,,, +shepherd, The GNU Shepherd Manual}). +@end table + +The following example defines an action called @code{say-hello} that kindly +greets the user: + +@example +(shepherd-action + (name 'say-hello) + (documentation "Say hi!") + (procedure #~(lambda (running . args) + (format #t "Hello, friend! arguments: ~s\n" + args) + #t))) +@end example + +Assuming this action is added to the @code{example} service, then you can do: + +@example +# herd say-hello example +Hello, friend! arguments: () +# herd say-hello example a b c +Hello, friend! arguments: ("a" "b" "c") +@end example + +This, as you can see, is a fairly sophisticated way to say hello. +@xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more +info on actions. +@end deftp + @defvr {Scheme Variable} shepherd-root-service-type The service type for the Shepherd ``root service''---i.e., PID@tie{}1. diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm index 6ca53faa3..4cd224984 100644 --- a/gnu/services/shepherd.scm +++ b/gnu/services/shepherd.scm @@ -49,6 +49,12 @@ shepherd-service-auto-start? shepherd-service-modules + shepherd-action + shepherd-action? + shepherd-action-name + shepherd-action-documentation + shepherd-action-procedure + %default-modules shepherd-service-file @@ -146,11 +152,20 @@ DEFAULT is given, use it as the service's default value." (start shepherd-service-start) ;g-expression (procedure) (stop shepherd-service-stop ;g-expression (procedure) (default #~(const #f))) + (actions shepherd-service-actions ;list of + (default '())) (auto-start? shepherd-service-auto-start? ;Boolean (default #t)) (modules shepherd-service-modules ;list of module names (default %default-modules))) +(define-record-type* + shepherd-action make-shepherd-action + shepherd-action? + (name shepherd-action-name) ;symbol + (procedure shepherd-action-procedure) ;gexp + (documentation shepherd-action-documentation)) ;string + (define (shepherd-service-canonical-name service) "Return the 'canonical name' of SERVICE." (first (shepherd-service-provision service))) @@ -223,7 +238,13 @@ stored." #:requires '#$(shepherd-service-requirement service) #:respawn? '#$(shepherd-service-respawn? service) #:start #$(shepherd-service-start service) - #:stop #$(shepherd-service-stop service)))))) + #:stop #$(shepherd-service-stop service) + #:actions + (make-actions + #$@(map (match-lambda + (($ name proc doc) + #~(#$name #$doc #$proc))) + (shepherd-service-actions service)))))))) (define (shepherd-configuration-file services) "Return the shepherd configuration file for SERVICES." -- 2.18.0 From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 11 17:55:28 2018 Received: (at 32128) by debbugs.gnu.org; 11 Jul 2018 21:55:28 +0000 Received: from localhost ([127.0.0.1]:56012 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fdN56-0005Ar-8l for submit@debbugs.gnu.org; Wed, 11 Jul 2018 17:55:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57735) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fdN54-0005AM-Bh for 32128@debbugs.gnu.org; Wed, 11 Jul 2018 17:55:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdN4x-00041q-UR for 32128@debbugs.gnu.org; Wed, 11 Jul 2018 17:55:21 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:59097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdN4v-00040r-AI; Wed, 11 Jul 2018 17:55:17 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=59732 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fdN4u-00012Z-RN; Wed, 11 Jul 2018 17:55:17 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 32128@debbugs.gnu.org Subject: [PATCH 2/2] services: mcron: Add 'schedule' action. Date: Wed, 11 Jul 2018 23:55:04 +0200 Message-Id: <20180711215504.30221-2-ludo@gnu.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180711215504.30221-1-ludo@gnu.org> References: <20180711215504.30221-1-ludo@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 32128 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Inspired by . * gnu/services/mcron.scm (shepherd-schedule-action): New procedure. (mcron-shepherd-services): Add 'actions' field. * gnu/tests/base.scm (run-mcron-test)["schedule action"]: New test. * doc/guix.texi (Scheduled Job Execution): Mention 'herd schedule'. --- doc/guix.texi | 15 ++++++++++ gnu/services/herd.scm | 3 ++ gnu/services/mcron.scm | 67 +++++++++++++++++++++++++++++++----------- gnu/tests/base.scm | 7 +++++ 4 files changed, 75 insertions(+), 17 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 0a6b2244d..8f72ab2b8 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -10844,6 +10844,21 @@ gexps to introduce job definitions that are passed to mcron for more information on mcron job specifications. Below is the reference of the mcron service. +On a running system, you can use the @code{schedule} action of the service to +visualize the mcron jobs that will be executed next: + +@example +# herd schedule mcron +@end example + +@noindent +The example above lists the next five tasks that will be executed, but you can +also specify the number of tasks to display: + +@example +# herd schedule mcron 10 +@end example + @deffn {Scheme Procedure} mcron-service @var{jobs} [#:mcron @var{mcron}] Return an mcron service running @var{mcron} that schedules @var{jobs}, a list of gexps denoting mcron job specifications. diff --git a/gnu/services/herd.scm b/gnu/services/herd.scm index d882c232c..8c96b7073 100644 --- a/gnu/services/herd.scm +++ b/gnu/services/herd.scm @@ -45,6 +45,7 @@ live-service-requirement live-service-running + with-shepherd-action current-services unload-services unload-service @@ -168,6 +169,8 @@ return #f." (define-syntax-rule (with-shepherd-action service (action args ...) result body ...) + "Invoke ACTION on SERVICE with the given ARGS, and evaluate BODY with RESULT +bound to the action's result." (invoke-action service action (list args ...) (lambda (result) body ...))) diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm index 5bee02a58..759d9c8b3 100644 --- a/gnu/services/mcron.scm +++ b/gnu/services/mcron.scm @@ -60,29 +60,62 @@ (define (job-file job) (scheme-file "mcron-job" job)) +(define (shepherd-schedule-action mcron files) + "Return a Shepherd action that runs MCRON with '--schedule' for the given +files." + (shepherd-action + (name 'schedule) + (documentation + "Display jobs that are going to be scheduled.") + (procedure + #~(lambda* (_ #:optional (n "5")) + ;; XXX: This is a global side effect. + (setenv "GUILE_AUTO_COMPILE" "0") + + ;; Run 'mcron' in a pipe so we can explicitly redirect its output to + ;; 'current-output-port', which at this stage is bound to the client + ;; connection. + (let ((pipe (open-pipe* OPEN_READ + #$(file-append mcron "/bin/mcron") + (string-append "--schedule=" n) + #$@files))) + (let loop () + (match (read-line pipe 'concat) + ((? eof-object?) + (zero? (close-pipe pipe))) + (line + (display line) + (loop))))))))) + (define mcron-shepherd-services (match-lambda (($ mcron ()) ;nothing to do! '()) (($ mcron jobs) - (list (shepherd-service - (provision '(mcron)) - (requirement '(user-processes)) - (modules `((srfi srfi-1) - (srfi srfi-26) - ,@%default-modules)) - (start #~(make-forkexec-constructor - (list (string-append #$mcron "/bin/mcron") - #$@(map job-file jobs)) + (let ((files (map job-file jobs))) + (list (shepherd-service + (provision '(mcron)) + (requirement '(user-processes)) + (modules `((srfi srfi-1) + (srfi srfi-26) + (ice-9 popen) ;for the 'schedule' action + (ice-9 rdelim) + (ice-9 match) + ,@%default-modules)) + (start #~(make-forkexec-constructor + (list (string-append #$mcron "/bin/mcron") #$@files) - ;; Disable auto-compilation of the job files and set a - ;; sane value for 'PATH'. - #:environment-variables - (cons* "GUILE_AUTO_COMPILE=0" - "PATH=/run/current-system/profile/bin" - (remove (cut string-prefix? "PATH=" <>) - (environ))))) - (stop #~(make-kill-destructor))))))) + ;; Disable auto-compilation of the job files and set a + ;; sane value for 'PATH'. + #:environment-variables + (cons* "GUILE_AUTO_COMPILE=0" + "PATH=/run/current-system/profile/bin" + (remove (cut string-prefix? "PATH=" <>) + (environ))))) + (stop #~(make-kill-destructor)) + + (actions + (list (shepherd-schedule-action mcron files))))))))) (define mcron-service-type (service-type (name 'mcron) diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm index 0efb4a6e5..f27064af8 100644 --- a/gnu/tests/base.scm +++ b/gnu/tests/base.scm @@ -632,6 +632,13 @@ non-ASCII names from /tmp.") (wait-for-file "/root/witness-touch" marionette #:read '(@ (ice-9 rdelim) read-string))) + ;; Make sure the 'schedule' action is accepted. + (test-equal "schedule action" + '(#t) ;one value, #t + (marionette-eval '(with-shepherd-action 'mcron ('schedule) result + result) + marionette)) + (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0))))) -- 2.18.0 From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 12 09:03:30 2018 Received: (at 32128) by debbugs.gnu.org; 12 Jul 2018 13:03:31 +0000 Received: from localhost ([127.0.0.1]:56469 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fdbFq-0000vj-Lq for submit@debbugs.gnu.org; Thu, 12 Jul 2018 09:03:30 -0400 Received: from mail.lassieur.org ([83.152.10.219]:40598) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fdbFo-0000va-Qe for 32128@debbugs.gnu.org; Thu, 12 Jul 2018 09:03:29 -0400 Received: from newt (smtp.parrot.biz [62.23.167.188]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id 7547f5b4 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Thu, 12 Jul 2018 13:03:27 +0000 (UTC) References: <20180711214717.29955-1-ludo@gnu.org> User-agent: mu4e 1.0; emacs 26.1 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#32128] [PATCH 0/2] Support custom actions for Shepherd services In-reply-to: <20180711214717.29955-1-ludo@gnu.org> Date: Thu, 12 Jul 2018 15:03:26 +0200 Message-ID: <87601k38td.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 32128 Cc: 32128@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Ludo, Ludovic Court=C3=A8s writes: > Hello Guix! > > This is a long-awaited feature=E2=80=94nothing fancy, but it can certainl= y be > useful as illustrated by the =E2=80=98herd schedule mcron=E2=80=99 exampl= e below. > > I suppose we can add actions for hot-swapping and reconfiguration of > services that support it, such as nginx: . This is fantastic! Thank you :-) And it looks good to me. 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. - It seems that sometimes the SIGCHLD handler is invoked, when the 'running' field is not yet set. Should CALL-WITH-BLOCKED-ASYNCS be used? =20=20 Cl=C3=A9ment From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 12 18:40:29 2018 Received: (at 32128-done) by debbugs.gnu.org; 12 Jul 2018 22:40:29 +0000 Received: from localhost ([127.0.0.1]:57513 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fdkGD-0001zq-5z for submit@debbugs.gnu.org; Thu, 12 Jul 2018 18:40:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39498) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fdkGB-0001ze-Nt for 32128-done@debbugs.gnu.org; Thu, 12 Jul 2018 18:40:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdkG5-0000gt-Au for 32128-done@debbugs.gnu.org; Thu, 12 Jul 2018 18:40:22 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:53628) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdkG5-0000gm-0q; Thu, 12 Jul 2018 18:40:21 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=45438 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fdkG4-0003Ln-KM; Thu, 12 Jul 2018 18:40:20 -0400 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Subject: Re: [bug#32128] [PATCH 0/2] Support custom actions for Shepherd services References: <20180711214717.29955-1-ludo@gnu.org> <87601k38td.fsf@lassieur.org> Date: Fri, 13 Jul 2018 00:40:18 +0200 In-Reply-To: <87601k38td.fsf@lassieur.org> (=?utf-8?Q?=22Cl=C3=A9ment?= Lassieur"'s message of "Thu, 12 Jul 2018 15:03:26 +0200") Message-ID: <871sc8qdrh.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 32128-done Cc: 32128-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Hello Cl=C3=A9ment, Cl=C3=A9ment Lassieur skribis: > Ludovic Court=C3=A8s writes: > >> Hello Guix! >> >> This is a long-awaited feature=E2=80=94nothing fancy, but it can certain= ly be >> useful as illustrated by the =E2=80=98herd schedule mcron=E2=80=99 examp= le below. >> >> I suppose we can add actions for hot-swapping and reconfiguration of >> services that support it, such as nginx: . > > This is fantastic! Thank you :-) And it looks good to me. Thanks! I=E2=80=99ve 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=E2=80=99s 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 =E2=80=9Cherd schedule mcron 50=E2=80=9D (=E2=80=9Cwaitpid: No child proces= ses=E2=80=9D), came from the fact that =E2=80=98close-pipe=E2=80=99 invokes =E2=80=98waitpid=E2=80=99, b= ut there=E2=80=99s a race with the Shepherd=E2=80=99s SIGCHLD handler, which might get to call =E2=80=98waitpi= d=E2=80=99 earlier. I=E2=80=99ve adjusted to code to protect against it but without blocking as= yncs, which seems safer. Thank you! Ludo=E2=80=99. From unknown Wed Jun 18 00:13:29 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 10 Aug 2018 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator