GNU bug report logs - #32433
[PATCH] services: nginx: Get the Shepherd to respawn NGINX.

Previous Next

Package: guix-patches;

Reported by: Clément Lassieur <clement <at> lassieur.org>

Date: Mon, 13 Aug 2018 21:49:01 UTC

Severity: normal

Tags: patch

Done: Clément Lassieur <clement <at> lassieur.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Clément Lassieur <clement <at> lassieur.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#32433: closed ([PATCH] services: nginx: Get the Shepherd to
 respawn NGINX.)
Date: Fri, 31 Aug 2018 14:39:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 31 Aug 2018 16:38:27 +0200
with message-id <87y3cmlhy4.fsf <at> lassieur.org>
and subject line Re: [bug#32433] [PATCH] services: nginx: Get the Shepherd to respawn NGINX.
has caused the debbugs.gnu.org bug report #32433,
regarding [PATCH] services: nginx: Get the Shepherd to respawn NGINX.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
32433: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=32433
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Clément Lassieur <clement <at> lassieur.org>
To: guix-patches <at> gnu.org
Subject: [PATCH] services: nginx: Get the Shepherd to respawn NGINX.
Date: Mon, 13 Aug 2018 23:47:50 +0200
* 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



[Message part 3 (message/rfc822, inline)]
From: Clément Lassieur <clement <at> lassieur.org>
To: 32433-done <at> debbugs.gnu.org
Subject: Re: [bug#32433] [PATCH] services: nginx: Get the Shepherd to respawn
 NGINX.
Date: Fri, 31 Aug 2018 16:38:27 +0200
Clément Lassieur <clement <at> 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!


This bug report was last modified 6 years and 325 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.