From: "Clément Lassieur" <clement@lassieur.org>
To: 32433@debbugs.gnu.org
Subject: [bug#32433] [PATCH] services: nginx: Get the Shepherd to respawn NGINX.
Date: Mon, 13 Aug 2018 23:47:50 +0200 [thread overview]
Message-ID: <20180813214750.714-1-clement@lassieur.org> (raw)
* 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
next reply other threads:[~2018-08-13 21:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-13 21:47 Clément Lassieur [this message]
2018-08-31 14:38 ` bug#32433: [PATCH] services: nginx: Get the Shepherd to respawn NGINX Clément Lassieur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180813214750.714-1-clement@lassieur.org \
--to=clement@lassieur.org \
--cc=32433@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).