[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 07/08: service: Define <systemd-service> and serialize it.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 07/08: service: Define <systemd-service> and serialize it. |
Date: |
Sat, 17 Feb 2024 13:07:19 -0500 (EST) |
civodul pushed a commit to branch devel
in repository shepherd.
commit 3de655fb5d641b6e5f297fa9792a3c6607e3f5ff
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sat Feb 17 19:02:07 2024 +0100
service: Define <systemd-service> and serialize it.
* modules/shepherd/service.scm (<systemd-service>): New record type.
(systemd-service->sexp): New serializer.
(make-systemd-constructor): Return a <systemd-service> record.
(make-systemd-destructor): Adjust accordingly.
---
modules/shepherd/service.scm | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 8274634..732b08b 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -2345,6 +2345,21 @@ rejecting connection from ~:[~a~;~*local process~].")
;;; systemd-style services.
;;;
+;; Representation of an systemd-style service.
+(define-record-type <systemd-service>
+ (systemd-service endpoints sockets)
+ systemd-service?
+ (endpoints systemd-service-endpoints)
+ (sockets systemd-service-sockets))
+
+(define-record-type-serializer (systemd-service->sexp
+ (service <systemd-service>))
+ `(systemd-service (version 0)
+ (endpoints
+ ,(map endpoint->sexp (systemd-service-endpoints service)))
+ (sockets
+ ,(map fileno (systemd-service-sockets service)))))
+
(define (wait-for-readable ports)
"Suspend the current task until one of @var{ports} is available for
reading."
@@ -2436,7 +2451,7 @@ This must be paired with @code{make-systemd-destructor}."
(change-service-value (process pid command))
(for-each close-port ports))))
- sockets))))
+ (systemd-service endpoints ports)))))
(define (make-systemd-destructor)
"Return a procedure that terminates a systemd-style service as created by
@@ -2447,8 +2462,8 @@ This must be paired with @code{make-systemd-destructor}."
(destroy process))
((? integer? pid) ;backward compatibility
(destroy pid))
- (((_ . (? port? socks)) ...)
- (for-each close-port socks)
+ ((? systemd-service? service)
+ (for-each close-port (systemd-service-sockets service))
#f))))
- [shepherd] branch devel updated (03e18f1 -> 5c87fef), Ludovic Courtès, 2024/02/17
- [shepherd] 01/08: service: Add ‘service-log-file’., Ludovic Courtès, 2024/02/17
- [shepherd] 02/08: herd: Display service log file when it is known., Ludovic Courtès, 2024/02/17
- [shepherd] 06/08: herd: Display information about inetd services., Ludovic Courtès, 2024/02/17
- [shepherd] 03/08: service: ‘make-inetd-forkexec-constructor’ returns a <process>., Ludovic Courtès, 2024/02/17
- [shepherd] 04/08: support: Add ‘socket-address->string’., Ludovic Courtès, 2024/02/17
- [shepherd] 05/08: service: Define <inetd-service> and serialize it., Ludovic Courtès, 2024/02/17
- [shepherd] 07/08: service: Define <systemd-service> and serialize it.,
Ludovic Courtès <=
- [shepherd] 08/08: herd: Display information about systemd services., Ludovic Courtès, 2024/02/17