summary refs log tree commit diff
path: root/gnu/services/web.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/services/web.scm')
-rw-r--r--gnu/services/web.scm29
1 files changed, 26 insertions, 3 deletions
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 3b9f9e40be..c8ffc19d83 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2019, 2020 Florian Pelz <pelzflorian@pelzflorian.de>
 ;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -151,6 +152,7 @@
             php-fpm-configuration-timezone
             php-fpm-configuration-workers-log-file
             php-fpm-configuration-file
+            php-fpm-configuration-php-ini-file
 
             php-fpm-dynamic-process-manager-configuration
             make-php-fpm-dynamic-process-manager-configuration
@@ -794,13 +796,29 @@ of index files."
 		      #:user #$user #:group #$group))
             (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
   (service-type (name 'fcgiwrap)
                 (extensions
                  (list (service-extension shepherd-root-service-type
                                           fcgiwrap-shepherd-service)
 		       (service-extension account-service-type
-                                          fcgiwrap-accounts)))
+                                          fcgiwrap-accounts)
+                       (service-extension activation-service-type
+                                          fcgiwrap-activation)))
                 (default-value (fcgiwrap-configuration))))
 
 (define-record-type* <php-fpm-configuration> php-fpm-configuration
@@ -839,6 +857,8 @@ of index files."
                                             (version-major (package-version php))
                                             "-fpm.www.log")))
   (file             php-fpm-configuration-file ;#f | file-like
+                    (default #f))
+  (php-ini-file     php-fpm-configuration-php-ini-file ;#f | file-like
                     (default #f)))
 
 (define-record-type* <php-fpm-dynamic-process-manager-configuration>
@@ -945,7 +965,7 @@ of index files."
   (match-lambda
     (($ <php-fpm-configuration> php socket user group socket-user socket-group
                                 pid-file log-file pm display-errors
-                                timezone workers-log-file file)
+                                timezone workers-log-file file php-ini-file)
      (list (shepherd-service
             (provision '(php-fpm))
             (documentation "Run the php-fpm daemon.")
@@ -956,7 +976,10 @@ of index files."
                         #$(or file
                               (default-php-fpm-config socket user group
                                 socket-user socket-group pid-file log-file
-                                pm display-errors timezone workers-log-file)))
+                                pm display-errors timezone workers-log-file))
+                        #$@(if php-ini-file
+                               `("-c" ,php-ini-file)
+                               '()))
                       #:pid-file #$pid-file))
             (stop #~(make-kill-destructor)))))))