aboutsummaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-07-11 23:17:37 +0200
committerLudovic Courtès <ludo@gnu.org>2018-07-13 00:08:54 +0200
commit701383081a9814d21823d42978ae23ee654e0427 (patch)
tree5e42455a1cbc0e033a8e0579474d9d1aa52718c8 /gnu
parent814bb8166804cc3c1f0dd1f1347786a1f07bd22b (diff)
downloadguix-701383081a9814d21823d42978ae23ee654e0427.tar
guix-701383081a9814d21823d42978ae23ee654e0427.tar.gz
services: shepherd: Support custom actions.
* gnu/services/shepherd.scm (<shepherd-service>)[actions]: New field. (<shepherd-action>): New record type. (shepherd-service-file): Pass #:actions to 'make'. * doc/guix.texi (Shepherd Services): Document custom actions.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/services/shepherd.scm23
1 files changed, 22 insertions, 1 deletions
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index 6ca53faa3d..4cd2249841 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 <shepherd-action>
+ (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>
+ 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
+ (($ <shepherd-action> name proc doc)
+ #~(#$name #$doc #$proc)))
+ (shepherd-service-actions service))))))))
(define (shepherd-configuration-file services)
"Return the shepherd configuration file for SERVICES."