services: dicod: Use 'make-inetd-constructor'.

* gnu/services/dict.scm (dicod-shepherd-service): Use
'make-inetd-constructor' in the 'start' method when available.
This commit is contained in:
Ludovic Courtès 2022-04-16 17:34:30 +02:00
parent 002bcb7eb0
commit fd57ce267c
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -146,6 +146,7 @@ (define %dicod-activation
(define (dicod-shepherd-service config) (define (dicod-shepherd-service config)
(let* ((dicod.conf (dicod-configuration-file config)) (let* ((dicod.conf (dicod-configuration-file config))
(interfaces (dicod-configuration-interfaces config))
(dicod (least-authority-wrapper (dicod (least-authority-wrapper
(file-append (dicod-configuration-dico config) (file-append (dicod-configuration-dico config)
"/bin/dicod") "/bin/dicod")
@ -165,10 +166,19 @@ (define (dicod-shepherd-service config)
(provision '(dicod)) (provision '(dicod))
(requirement '(user-processes)) (requirement '(user-processes))
(documentation "Run the dicod daemon.") (documentation "Run the dicod daemon.")
(start #~(make-forkexec-constructor (start #~(if (and (defined? 'make-inetd-constructor)
(list #$dicod "--foreground" #$(= 1 (length interfaces))) ;XXX
(string-append "--config=" #$dicod.conf)) (make-inetd-constructor
#:user "dicod" #:group "dicod")) (list #$dicod "--inetd" "--foreground"
(string-append "--config=" #$dicod.conf))
(addrinfo:addr
(car (getaddrinfo #$(first interfaces) "dict")))
#:user "dicod" #:group "dicod"
#:service-name-stem "dicod")
(make-forkexec-constructor
(list #$dicod "--foreground"
(string-append "--config=" #$dicod.conf))
#:user "dicod" #:group "dicod")))
(stop #~(make-kill-destructor)))))) (stop #~(make-kill-destructor))))))
(define dicod-service-type (define dicod-service-type