guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 05/12: service: 'start-in-the-background' starts services in


From: Ludovic Courtès
Subject: [shepherd] 05/12: service: 'start-in-the-background' starts services in parallel.
Date: Sun, 19 Feb 2023 16:58:36 -0500 (EST)

civodul pushed a commit to branch wip-service-monitor
in repository shepherd.

commit e0cae14f8e42290f9b318090c59eb886e1c7ce16
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Feb 17 22:20:27 2023 +0100

    service: 'start-in-the-background' starts services in parallel.
    
    * modules/shepherd/service.scm (start-in-the-background): Use
    'start-in-parallel' instead of 'for-each'.
---
 modules/shepherd/service.scm | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 0d7c2e1..29f568e 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -946,14 +946,21 @@ This procedure can be useful in a configuration file 
because it lets you
 interact right away with shepherd using the @command{herd} command."
   (spawn-fiber
    (lambda ()
-     (for-each (lambda (service)
-                 ;; Keep going if one of SERVICES fails to start.
-                 (guard (c ((service-error? c)
-                            (local-output
-                             (l10n "Failed to start ~a in the background.")
-                             service)))
-                   (start service)))
-               services)))
+     (match (start-in-parallel services)
+       (()
+        (local-output
+         (l10n "Successfully started ~a service in the background."
+               "Successfully started ~a services in the background."
+               (length services))
+         (length services)))
+       (failures
+        (local-output
+         (l10n "The following service could not be started in the \
+background:~{ ~a~}."
+               "The following services could not be started in the \
+background:~{ ~a~}."
+               (length failures))
+         failures)))))
 
   ;; 'spawn-fiber' returns zero values, which can confuse callees; return one.
   *unspecified*)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]