unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#32433] [PATCH] services: nginx: Get the Shepherd to respawn NGINX.
@ 2018-08-13 21:47 Clément Lassieur
  2018-08-31 14:38 ` bug#32433: " Clément Lassieur
  0 siblings, 1 reply; 2+ messages in thread
From: Clément Lassieur @ 2018-08-13 21:47 UTC (permalink / raw)
  To: 32433

* 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 97976509b..467656444 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))
-                         #$@args)))))
+                         #$@args)
+                 (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")))))))
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#32433: [PATCH] services: nginx: Get the Shepherd to respawn NGINX.
  2018-08-13 21:47 [bug#32433] [PATCH] services: nginx: Get the Shepherd to respawn NGINX Clément Lassieur
@ 2018-08-31 14:38 ` Clément Lassieur
  0 siblings, 0 replies; 2+ messages in thread
From: Clément Lassieur @ 2018-08-31 14:38 UTC (permalink / raw)
  To: 32433-done

Clément Lassieur <clement@lassieur.org> writes:

> * 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(-)

Pushed!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-31 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-13 21:47 [bug#32433] [PATCH] services: nginx: Get the Shepherd to respawn NGINX Clément Lassieur
2018-08-31 14:38 ` bug#32433: " Clément Lassieur

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).