[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 08/09: service: Provide 'service' constructor.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 08/09: service: Provide 'service' constructor. |
Date: |
Wed, 5 Apr 2023 17:33:59 -0400 (EDT) |
civodul pushed a commit to branch wip-goopsless
in repository shepherd.
commit 3a955bd6f6b83be4814f61f498db460ed779e08c
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Apr 5 23:28:28 2023 +0200
service: Provide 'service' constructor.
This is meant to supersede (make <service> ...).
* modules/shepherd/service.scm (service): New procedure.
(make-inetd-constructor, root-service): Use it instead of 'make'.
---
modules/shepherd/service.scm | 44 ++++++++++++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 8 deletions(-)
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index d42c386..0b0b5a2 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -50,6 +50,7 @@
#:use-module (shepherd config)
#:use-module (shepherd system)
#:export (<service>
+ service
service?
service-provision
service-requirement
@@ -292,6 +293,32 @@ Log abnormal termination reported by @var{status}."
;; requests such as 'start' and 'stop' on this channels.
(control #:init-value #f))
+;; The procedure below supersedes (make <service> ...).
+(define* (service provision
+ #:key
+ (requirement '())
+ (one-shot? #f)
+ (transient? #f)
+ (respawn? #f)
+ (start (lambda () #t))
+ (stop (lambda (running) #f))
+ (actions (make-actions))
+ (termination-handler default-service-termination-handler)
+ (documentation (l10n "[No description].")))
+ "Return a new service with the given @var{provision}, a list of symbols
+denoting what the service provides."
+ (make <service>
+ #:provides provision
+ #:requires requirement
+ #:one-shot? one-shot?
+ #:transient? transient?
+ #:respawn? respawn?
+ #:start start
+ #:stop stop
+ #:actions actions
+ #:handle-termination termination-handler
+ #:docstring documentation))
+
(define (service-control service)
"Return the controlling channel of @var{service}."
;; Spawn the controlling fiber lazily, hopefully once Fibers has actually
@@ -1926,9 +1953,9 @@ The remaining arguments are as for
@code{make-forkexec-constructor}."
(define (spawn-child-service connection server-address client-address)
(let* ((name (child-service-name))
- (service (make <service>
- #:provides (list name)
- #:requires requirements
+ (service (service
+ (list name)
+ #:requirement requirements
#:respawn? #f
#:transient? #t
#:start (make-inetd-forkexec-constructor
@@ -1945,7 +1972,7 @@ The remaining arguments are as for
@code{make-forkexec-constructor}."
client-address)
environment-variables)
#:resource-limits resource-limits)
- #:handle-termination handle-child-termination
+ #:termination-handler handle-child-termination
#:stop (make-kill-destructor))))
(register-services service)
(start service)))
@@ -2533,10 +2560,11 @@ where prctl/PR_SET_CHILD_SUBREAPER is unsupported."
(respawn-service service))))))
(define root-service
- (make <service>
- #:docstring "The root service is used to operate on shepherd itself."
- #:provides '(root shepherd)
- #:requires '()
+ (service
+ '(root shepherd)
+ #:documentation
+ (l10n "The root service is used to operate on shepherd itself.")
+ #:requirement '()
#:respawn? #f
#:start (lambda args
(when (isatty? (current-output-port))
- [shepherd] branch wip-goopsless created (now 6f7228f), Ludovic Courtès, 2023/04/05
- [shepherd] 03/09: service: Rename <service> getters following Scheme conventions., Ludovic Courtès, 2023/04/05
- [shepherd] 02/09: comm: Remove use of (oop goops)., Ludovic Courtès, 2023/04/05
- [shepherd] 01/09: args: Remove use of (oop goops)., Ludovic Courtès, 2023/04/05
- [shepherd] 04/09: service: Add getters for <service> and remove uses of 'slot-ref'., Ludovic Courtès, 2023/04/05
- [shepherd] 07/09: service: Mark action and state methods as deprecated., Ludovic Courtès, 2023/04/05
- [shepherd] 08/09: service: Provide 'service' constructor.,
Ludovic Courtès <=
- [shepherd] 05/09: Remove example of the 'unknown' service., Ludovic Courtès, 2023/04/05
- [shepherd] 06/09: service: Replace 'canonical-name' method with 'service-canonical-name'., Ludovic Courtès, 2023/04/05
- [shepherd] 09/09: service: Use 'service' procedure to replace (make <service> ...)., Ludovic Courtès, 2023/04/05