[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
09/12: services: shepherd: Define 'shepherd-configuration-action' helper
From: |
guix-commits |
Subject: |
09/12: services: shepherd: Define 'shepherd-configuration-action' helper. |
Date: |
Fri, 18 Nov 2022 09:49:14 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit ebc7de6a1efb702fd0364128cbde19697966c4f4
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Nov 11 18:54:25 2022 +0100
services: shepherd: Define 'shepherd-configuration-action' helper.
* gnu/services/shepherd.scm (shepherd-configuration-action): New
* doc/guix.texi (Shepherd Services): Document it.
---
doc/guix.texi | 33 +++++++++++++++++++++++++++++++++
gnu/services/shepherd.scm | 12 ++++++++++++
2 files changed, 45 insertions(+)
diff --git a/doc/guix.texi b/doc/guix.texi
index 2d4f7d960e..9dddaf4f2f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -39999,6 +39999,39 @@ This, as you can see, is a fairly sophisticated way to
say hello.
info on actions.
@end deftp
+@cindex configuration file, of Shepherd services
+@deffn {Scheme Procedure} shepherd-configuration-action
+Return a @code{configuration} action to display @var{file}, which should
+be the name of the service's configuration file.
+
+It can be useful to equip services with that action. For example, the
+service for the Tor anonymous router (@pxref{Networking Services,
+@code{tor-service-type}}) is defined roughly like this:
+
+@lisp
+(let ((torrc (plain-file "torrc" @dots{})))
+ (shepherd-service
+ (provision '(tor))
+ (requirement '(user-processes loopback syslogd))
+
+ (start #~(make-forkexec-constructor
+ (list #$(file-append tor "/bin/tor") "-f" #$torrc)
+ #:user "tor" #:group "tor"))
+ (stop #~(make-kill-destructor))
+ (actions (list (shepherd-configuration-action torrc)))
+ (documentation "Run the Tor anonymous network overlay.")))
+@end lisp
+
+Thanks to this action, administrators can inspect the configuration file
+passed to @command{tor} with this shell command:
+
+@example
+cat $(herd configuration tor)
+@end example
+
+This can come in as a handy debugging tool!
+@end deffn
+
@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 7110e5aa89..b2601c0128 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -66,6 +66,8 @@
shepherd-action-documentation
shepherd-action-procedure
+ shepherd-configuration-action
+
%default-modules
shepherd-service-file
@@ -333,6 +335,16 @@ and return the resulting '.go' file. SHEPHERD is used as
shepherd package."
#:options '(#:local-build? #t
#:substitutable? #f)))))
+(define (shepherd-configuration-action file)
+ "Return a 'configuration' action to display FILE, which should be the name
+of the service's configuration file."
+ (shepherd-action
+ (name 'configuration)
+ (documentation "Display the name of this service's configuration file.")
+ (procedure #~(lambda (_)
+ (format #t "~a~%" #$file)
+ #$file))))
+
(define (shepherd-configuration-file services shepherd)
"Return the shepherd configuration file for SERVICES. SHEPHERD is used
as shepherd package."
- branch master updated (383b0f0590 -> 2a358911b0), guix-commits, 2022/11/18
- 03/12: import/utils: spdx-string->license: Match case-insensitively., guix-commits, 2022/11/18
- 10/12: services: Add Shepherd 'configuration' action to various services., guix-commits, 2022/11/18
- 04/12: import/utils: spdx-string->license: Support '+' operator., guix-commits, 2022/11/18
- 01/12: linux-initrd: raw-initrd: Add keyword argument #:pre-mount., guix-commits, 2022/11/18
- 12/12: services: tor: Remove unnecessary modules from shepherd environment., guix-commits, 2022/11/18
- 06/12: gnu: s3cmd: Fix program name in output., guix-commits, 2022/11/18
- 07/12: gnu: tbb: Update to 2021.6.0., guix-commits, 2022/11/18
- 09/12: services: shepherd: Define 'shepherd-configuration-action' helper.,
guix-commits <=
- 08/12: gnu: timescaledb: Update to 2.8.1., guix-commits, 2022/11/18
- 11/12: home: services: redshift: Add 'configuration' action., guix-commits, 2022/11/18
- 02/12: import/utils: spdx-string->license: Fix incorrect docstring., guix-commits, 2022/11/18
- 05/12: gnu: Add wld., guix-commits, 2022/11/18