GNU bug report logs - #77109
[feature] [shepherd] Accept multiple services for actions

Previous Next

Package: guix;

Reported by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Date: Wed, 19 Mar 2025 06:04:02 UTC

Severity: normal

Full log


Message #20 received at 77109 <at> debbugs.gnu.org (full text, mbox):

From: Tomas Volf <~@wolfsden.cz>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 77109 <at> debbugs.gnu.org, Ludovic Courtès <ludo <at> gnu.org>
Subject: Re: bug#77109: [feature] [shepherd] Accept multiple services for
 actions
Date: Fri, 21 Mar 2025 00:34:28 +0100
Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:

>> I am not sure having different semantics for restart and any other
>> action is a good idea though.
>>
>> But what I think would be a good idea is for start, stop, restart to
>> signal an error when additional unexpected arguments are provided.
>
> Failing to change the behavior as suggested, that would still be an
> improvement, yes.  But then you'd also be special casing these actions,
> as actions are designed to receive an arbitrary number of arguments and
> cannot forcibly know which ones are really used/necessary in advance?

But the default implementation of `restart' knows it takes no arguments.
So something like the following.

--8<---------------cut here---------------start------------->8---
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 79d14cf..68c4cca 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -1115,6 +1115,10 @@ the action."
       ;; Restarting is done in the obvious way.
       ((restart)
        (lambda (running . args)
+         (unless (null? args)
+           (local-output
+            (l10n "Action `restart' of ~a takes no arguments.")
+            (service-canonical-name service)))
          (let ((stopped-services (stop-service service)))
            (for-each start-service
                      (remove transient-service? stopped-services))
--8<---------------cut here---------------end--------------->8---

Dunno, just an (untested) idea. ¯\_(ツ)_/¯

Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.




This bug report was last modified 82 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.