From 0add6760a62dbd67501b6a50feaf42d2edb8ca30 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 3 Jan 2019 16:54:06 +0100 Subject: fix permission adjustment --- guix/fixed-fcgiwrap.scm | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'guix') diff --git a/guix/fixed-fcgiwrap.scm b/guix/fixed-fcgiwrap.scm index c5f84b0..21b39d6 100644 --- a/guix/fixed-fcgiwrap.scm +++ b/guix/fixed-fcgiwrap.scm @@ -7,6 +7,7 @@ #:use-module (gnu packages web) #:use-module (gnu services shepherd) #:use-module (guix modules) + #:use-module (guix i18n) #:use-module (guix records) #:use-module (guix gexp) #:export (fcgiwrap-configuration @@ -89,7 +90,7 @@ (provision '(fcgiwrap)) (documentation "Run the fcgiwrap daemon.") (requirement '(networking)) - (modules `((ice-9 match) ,@%default-modules)) + (modules `((shepherd support) (ice-9 match) ,@%default-modules)) (start #~(lambda args (define (clean-up file) @@ -99,15 +100,21 @@ (lambda args (unless (= ENOENT (system-error-errno args)) (apply throw args))))) - (define* (wait-for-file file #:key (max-delay 5)) + (define* (wait-for-file file #:key (max-delay 10)) (define start (current-time)) + (local-output "w: waiting for file ~s" file) (let loop () (cond - ((file-exists? file) #t) + ((file-exists? file) + (local-output "w: file ~s exists" file) + #t) ((< (current-time) (+ start max-delay)) + (local-output "w: file ~s does not exist yet" file) (sleep 1) (loop)) - (else #f)))) + (else + (local-output "w: file ~s: giving up" file) + #f)))) (define (adjust-permissions file mode) (match mode (#t (chmod file #o660)) @@ -132,12 +139,14 @@ (clean-up path) (when #$ensure-dir? (ensure-socket-dir (dirname path) #$user #$group)) - (let ((pid (start-fcgiwrap))) - (cond - ((wait-for-file path) - (adjust-permissions path perm) - pid) - (else #f)))) + (let ((pid (start-fcgiwrap)) + (socket-exists? (wait-for-file path))) + (if socket-exists? + (adjust-permissions path #$perm) + (local-output + #$(G_ "fcgiwrap: warning: waiting for socket ~s failed") + path)) + pid)) (_ (start-fcgiwrap))))) (stop #~(make-kill-destructor))))))) -- cgit v1.2.3