From 701383081a9814d21823d42978ae23ee654e0427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 11 Jul 2018 23:17:37 +0200 Subject: services: shepherd: Support custom actions. * gnu/services/shepherd.scm ()[actions]: New field. (): New record type. (shepherd-service-file): Pass #:actions to 'make'. * doc/guix.texi (Shepherd Services): Document custom actions. --- gnu/services/shepherd.scm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'gnu/services/shepherd.scm') 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 + (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 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 + (($ name proc doc) + #~(#$name #$doc #$proc))) + (shepherd-service-actions service)))))))) (define (shepherd-configuration-file services) "Return the shepherd configuration file for SERVICES." -- cgit v1.2.3