services: fcgiwrap: Create parent directory for unix socket.

* gnu/services/web.scm (fcgiwrap-activation): New function.
(fcgiwrap-service-type): Extend activation-service-type with
fcgiwrap-activation.
This commit is contained in:
Arun Isaac 2020-08-18 23:08:26 +05:30
parent 6a9581741e
commit 17881f944e
No known key found for this signature in database
GPG key ID: 2E25EE8B61802BB3

View file

@ -12,6 +12,7 @@
;;; Copyright © 2019, 2020 Florian Pelz <pelzflorian@pelzflorian.de> ;;; Copyright © 2019, 2020 Florian Pelz <pelzflorian@pelzflorian.de>
;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -794,13 +795,29 @@ (define fcgiwrap-shepherd-service
#:user #$user #:group #$group)) #:user #$user #:group #$group))
(stop #~(make-kill-destructor))))))) (stop #~(make-kill-destructor)))))))
(define fcgiwrap-activation
(match-lambda
(($ <fcgiwrap-configuration> package socket user group)
#~(begin
;; When listening on a unix socket, create a parent directory for the
;; socket with the correct permissions.
(when (string-prefix? "unix:" #$socket)
(let ((run-directory
(dirname (substring #$socket (string-length "unix:")))))
(mkdir-p run-directory)
(chown run-directory
(passwd:uid (getpw #$user))
(group:gid (getgr #$group)))))))))
(define fcgiwrap-service-type (define fcgiwrap-service-type
(service-type (name 'fcgiwrap) (service-type (name 'fcgiwrap)
(extensions (extensions
(list (service-extension shepherd-root-service-type (list (service-extension shepherd-root-service-type
fcgiwrap-shepherd-service) fcgiwrap-shepherd-service)
(service-extension account-service-type (service-extension account-service-type
fcgiwrap-accounts))) fcgiwrap-accounts)
(service-extension activation-service-type
fcgiwrap-activation)))
(default-value (fcgiwrap-configuration)))) (default-value (fcgiwrap-configuration))))
(define-record-type* <php-fpm-configuration> php-fpm-configuration (define-record-type* <php-fpm-configuration> php-fpm-configuration