unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: 54986@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>,
	"Maxime Devos" <maximedevos@telenet.be>
Subject: [bug#54986] [PATCH v3 1/2] services: shepherd: Add support for socket activation endpoints.
Date: Sat, 23 Apr 2022 16:25:55 +0200	[thread overview]
Message-ID: <684304748f200de9493550d079d59dc8cfe2b002.camel@gmail.com> (raw)
In-Reply-To: <9d4cc9d3ebb05d2aabf8f06e1890efe9b0b9a849.camel@gmail.com>

* gnu/services/shepherd.scm (<shepherd-endpoint>): New record type.
(shepherd-endpoint->sexp): New variable.
* doc/guix.texi (Shepherd Services): Document it.
---
 doc/guix.texi             | 32 ++++++++++++++++++++
 gnu/services/shepherd.scm | 64 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index c21235f28d..30cc3b6d45 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -39332,6 +39332,38 @@ This, as you can see, is a fairly sophisticated way to say hello.
 info on actions.
 @end deftp
 
+@deftp {Data Type} shepherd-endpoint
+This data type represents an endpoint for inetd-style and systemd-style
+services.  Its fields reflect the arguments to shepherd's
+@code{endpoint} procedure.
+
+@table @code
+@item address
+The socket address to bind via shepherd and forward to the service.
+
+@item name
+A ``descriptive'' name to forward to the service along with the socket.
+
+@item style
+The socket style to use.
+@xref{Network Sockets and Communication,,, guile, GNU Guile Reference
+Manual}.
+
+@item backlog
+The maximum length of the queue for pending connections.
+
+@item socket-owner
+The user ID owning the socket.
+
+@item socket-group
+The group ID owning the socket.
+
+@item socket-directory-permissions
+The UNIX permissions to set for the directory the socket resides in.
+
+@end table
+@end deftp
+
 @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 4fd4b2a497..f0d204ff3a 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -66,6 +66,17 @@ (define-module (gnu services shepherd)
             shepherd-action-documentation
             shepherd-action-procedure
 
+            shepherd-endpoint
+            shepherd-endpoint?
+            shepherd-endpoint-address
+            shepherd-endpoint-name
+            shepherd-endpoint-style
+            shepherd-endpoint-backlog
+            shepherd-endpoint-socket-owner
+            shepherd-endpoint-socket-group
+            shepherd-endpoint-socket-directory-permissions
+            shepherd-endpoint->sexp
+
             %default-modules
 
             shepherd-service-file
@@ -183,6 +194,59 @@ (define %default-modules
     ((guix build utils) #:hide (delete))
     (guix build syscalls)))
 
+(define-record-type* <shepherd-endpoint>
+  shepherd-endpoint make-shepherd-endpoint
+  shepherd-endpoint?
+  (address                      shepherd-endpoint-address)      ; sockaddr
+  (name                         shepherd-endpoint-name          ; string | #f
+                                (default #f))
+  (style                        shepherd-endpoint-style         ; int | #f
+                                (default #f))
+  (backlog                      shepherd-endpoint-backlog       ; int | #f
+                                (default #f))
+  (socket-owner                 shepherd-endpoint-socket-owner  ; uid | #f
+                                (default #f))
+  (socket-group                 shepherd-endpoint-socket-group  ; gid | #f
+                                (default #f))
+  (socket-directory-permissions
+   shepherd-endpoint-socket-directory-permissions ; chmod pattern (int) | #f
+   (default #f)))
+
+(define (shepherd-endpoint->sexp endpoint)
+  (match endpoint
+    (($ <shepherd-endpoint> address
+                            name style backlog socket-owner socket-group
+                            socket-directory-permissions)
+     `(endpoint
+       ,(match (sockaddr:fam address)
+          ((? (cute = <> AF_INET) _)
+           `((@ (guile) make-socket-addr)
+             AF_INET
+             ,(sockaddr:addr address)
+             ,(sockaddr:port address)))
+          ((? (cute = <> AF_INET6) _)
+           `((@ (guile) make-socket-addr)
+             AF_INET6
+             ,(sockaddr:addr address)
+             ,(sockaddr:port address)
+             ,(sockaddr:flowinfo address)
+             ,(sockaddr:scopeid address)))
+          ((? (cute = <> AF_UNIX) _)
+           `((@ (guile) make-socket-addr)
+             AF_UNIX
+             ,(sockaddr:path address))))
+       ,@(fold
+          (match-lambda*
+            (((key value) seed)
+             (if value (cons* key value seed) seed)))
+          '()
+          `((#:name ,name)
+            (#:style ,style)
+            (#:backlog ,backlog)
+            (#:socket-owner ,socket-owner)
+            (#:socket-group ,socket-group)
+            (#:socket-directory-permissions ,socket-directory-permissions)))))))
+
 (define-record-type* <shepherd-service>
   shepherd-service make-shepherd-service
   shepherd-service?
-- 
2.37.3





  parent reply	other threads:[~2022-09-10 18:32 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-17 10:01 [bug#54986] [PATCH] gnu: mpd: Add support for socket activation Liliana Marie Prikler
2022-04-17 10:01 ` [bug#54986] [PATCH v2 1/3] " Liliana Marie Prikler
2022-04-17 21:06 ` [bug#54986] [PATCH] " Ludovic Courtès
2022-04-17 21:57   ` Liliana Marie Prikler
2022-04-18 21:05     ` Ludovic Courtès
2022-04-18 21:19       ` Liliana Marie Prikler
2022-04-27 20:56         ` Ludovic Courtès
2022-04-28 16:45           ` Liliana Marie Prikler
2022-04-23 14:25 ` Liliana Marie Prikler [this message]
2023-04-26  0:33   ` Maxim Cournoyer
2023-04-26  4:28     ` Liliana Marie Prikler
2023-05-01 15:53       ` Maxim Cournoyer
2023-05-01 16:09         ` Liliana Marie Prikler
2023-05-03  3:17           ` Maxim Cournoyer
2023-05-03 13:27           ` Ludovic Courtès
2023-05-03 16:54             ` Liliana Marie Prikler
2023-05-10 15:14               ` Ludovic Courtès
2023-05-10 18:32                 ` Liliana Marie Prikler
2023-05-11 10:52                   ` Ludovic Courtès
2022-04-23 14:25 ` [bug#54986] [PATCH v2 2/3 WIP] services: shepherd: Add support for socket activation endpoints Liliana Marie Prikler
2022-04-27 22:05   ` Ludovic Courtès
2022-04-23 14:39 ` [bug#54986] [PATCH v2 3/3 WIP] services: mpd: Support socket activation Liliana Marie Prikler
2022-04-23 17:31   ` Maxime Devos
2022-04-23 18:36     ` Liliana Marie Prikler
2022-04-23 17:35   ` Maxime Devos
2022-04-23 18:28     ` Liliana Marie Prikler
2022-04-27 22:08   ` Ludovic Courtès
2022-05-13 15:55     ` [bug#54986] [PATCH] gnu: mpd: Add support for " Ludovic Courtès
2022-05-13 17:00       ` Liliana Marie Prikler
2022-04-23 14:39 ` [bug#54986] [PATCH v3 2/2] services: mpd: Support " Liliana Marie Prikler
2022-10-23 11:38   ` Liliana Marie Prikler
2022-11-26 12:59     ` Liliana Marie Prikler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=684304748f200de9493550d079d59dc8cfe2b002.camel@gmail.com \
    --to=liliana.prikler@gmail.com \
    --cc=54986@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    --cc=maximedevos@telenet.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).