guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: services: nginx: Get the Shepherd to respawn NGINX.


From: Clément Lassieur
Subject: 01/01: services: nginx: Get the Shepherd to respawn NGINX.
Date: Fri, 31 Aug 2018 10:36:25 -0400 (EDT)

snape pushed a commit to branch master
in repository guix.

commit 9fc2922794ffaae48e0a7c536e530ea2e0d46cf3
Author: Clément Lassieur <address@hidden>
Date:   Mon Aug 13 21:05:55 2018 +0200

    services: nginx: Get the Shepherd to respawn NGINX.
    
    * gnu/services/web.scm (nginx-shepherd-service): Change 'start' (that is, 
all
    actions that don't send a signal to the master process) to return the PID.
    Wait until the PID file is created and contains an integer because it might 
be
    created after the parent process exits.
---
 gnu/services/web.scm | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 9797650..4676564 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -599,19 +599,33 @@ of index files."
                 <nginx-configuration>
                 (nginx file run-directory)
    (let* ((nginx-binary (file-append nginx "/sbin/nginx"))
+          (pid-file (in-vicinity run-directory "pid"))
           (nginx-action
            (lambda args
              #~(lambda _
                  (invoke #$nginx-binary "-c"
                          #$(or file
                                (default-nginx-config config))
-                         address@hidden)))))
+                         address@hidden)
+                 (match '#$args
+                   (("-s" . _) #t)
+                   (_
+                    (let loop ((duration 0))
+                      ;; 
https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1581864/comments/7
+                      (sleep duration)
+                      (if (file-exists? #$pid-file)
+                          (let ((pid (call-with-input-file #$pid-file read)))
+                            ;; it could be #<eof>
+                            (if (integer? pid) pid (loop 1)))
+                          (loop 1)))))))))
 
      ;; TODO: Add 'reload' action.
      (list (shepherd-service
             (provision '(nginx))
             (documentation "Run the nginx daemon.")
             (requirement '(user-processes loopback))
+            (modules `((ice-9 match)
+                       ,@%default-modules))
             (start (nginx-action "-p" run-directory))
             (stop (nginx-action "-s" "stop")))))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]