[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 17/24: service: Add 'start-in-the-background'.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 17/24: service: Add 'start-in-the-background'. |
Date: |
Mon, 28 Mar 2022 17:24:47 -0400 (EDT) |
civodul pushed a commit to branch wip-fibers
in repository shepherd.
commit 8276c96d385b03c958aa1393e080ad8cbd5147bb
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun Mar 27 22:21:45 2022 +0200
service: Add 'start-in-the-background'.
* modules/shepherd/service.scm (start-in-the-background): New procedure.
* doc/shepherd.texi (Service Convenience): Document it.
---
doc/shepherd.texi | 9 +++++++++
modules/shepherd/service.scm | 18 ++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/doc/shepherd.texi b/doc/shepherd.texi
index c5db660..4175c24 100644
--- a/doc/shepherd.texi
+++ b/doc/shepherd.texi
@@ -861,6 +861,15 @@ current value of the @code{running} slot of the service.
Start a registered service providing @var{obj}.
@end deffn
+@deffn {procedure} start-in-the-background @var{services}
+Start the services named by @var{services}, a list of symbols, in the
+background. In other words, this procedure returns immediately without
+waiting until all of @var{services} have been started.
+
+This procedure can be useful in a configuration file because it lets you
+interact right away with shepherd using the @command{herd} command.
+@end deffn
+
@deffn {method} stop (obj <symbol>)
Stop a registered service providing @var{obj}.
@end deffn
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 55e8307..614205b 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -58,6 +58,7 @@
enable
disable
start
+ start-in-the-background
stop
action
enforce
@@ -678,6 +679,23 @@ results."
(apply action service the-action args))
which-services))))
+(define (start-in-the-background services)
+ "Start the services named by @var{services}, a list of symbols, in the
+background. In other words, this procedure returns immediately without
+waiting until all of @var{services} have been started.
+
+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))))
- [shepherd] branch wip-fibers created (now 8664372), Ludovic Courtès, 2022/03/28
- [shepherd] 02/24: build: Drop support for Guile 2.0., Ludovic Courtès, 2022/03/28
- [shepherd] 03/24: Use Fibers., Ludovic Courtès, 2022/03/28
- [shepherd] 05/24: shepherd: Use one fiber for signal handling, and one for clients., Ludovic Courtès, 2022/03/28
- [shepherd] 08/24: shepherd: Encode log as UTF-8 unconditionally., Ludovic Courtès, 2022/03/28
- [shepherd] 10/24: doc: Fix inetutils cross-reference., Ludovic Courtès, 2022/03/28
- [shepherd] 12/24: service: Remove unused 'make-init.d-service'., Ludovic Courtès, 2022/03/28
- [shepherd] 13/24: service: Add the #:transient? slot., Ludovic Courtès, 2022/03/28
- [shepherd] 18/24: shepherd: Remove half-baked readline support., Ludovic Courtès, 2022/03/28
- [shepherd] 19/24: shepherd: "shepherd -s -" replies to the current output port., Ludovic Courtès, 2022/03/28
- [shepherd] 17/24: service: Add 'start-in-the-background'.,
Ludovic Courtès <=
- [shepherd] 14/24: service: Add inetd constructor and destructor., Ludovic Courtès, 2022/03/28
- [shepherd] 15/24: service: Allow 'running' value to be a thunk., Ludovic Courtès, 2022/03/28
- [shepherd] 20/24: service: Add #:handle-termination slot., Ludovic Courtès, 2022/03/28
- [shepherd] 22/24: service: 'make-inetd-constructor' lets the caller specify socket ownership., Ludovic Courtès, 2022/03/28
- [shepherd] 06/24: service: 'read-pid-file' no longer blocks., Ludovic Courtès, 2022/03/28
- [shepherd] 09/24: service: 'make-forkexec-constructor' spawns a logging fiber., Ludovic Courtès, 2022/03/28
- [shepherd] 16/24: service: Add systemd constructor and destructor., Ludovic Courtès, 2022/03/28
- [shepherd] 11/24: support: 'l10n' accepts plural forms., Ludovic Courtès, 2022/03/28
- [shepherd] 01/24: shepherd: Factorize out the main loop., Ludovic Courtès, 2022/03/28
- [shepherd] 04/24: build: Capture the source and object directories of Fibers., Ludovic Courtès, 2022/03/28