From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Cl=C3=A9ment?= Lassieur Subject: bug#32665: Shepherd is stuck waiting for /var/run/nginx/pid Date: Sat, 08 Sep 2018 19:16:41 +0200 Message-ID: <8736ujq58m.fsf@lassieur.org> References: <87zhwsdj7q.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fygtz-0006jc-Jk for bug-guix@gnu.org; Sat, 08 Sep 2018 13:20:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fygtv-0000dh-JL for bug-guix@gnu.org; Sat, 08 Sep 2018 13:20:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:45547) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fygtu-0000a5-DK for bug-guix@gnu.org; Sat, 08 Sep 2018 13:20:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fygtu-0008On-2v for bug-guix@gnu.org; Sat, 08 Sep 2018 13:20:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fygsz-00062T-6n for bug-guix@gnu.org; Sat, 08 Sep 2018 13:19:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fygqm-0007ON-Rt for bug-guix@gnu.org; Sat, 08 Sep 2018 13:16:49 -0400 In-reply-to: <87zhwsdj7q.fsf@gnu.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 32665@debbugs.gnu.org Oh! Sorry for the mess. The patches both look good to me, thank you! Cl=C3=A9ment Ludovic Court=C3=A8s writes: > Hello Cl=C3=A9ment, > > Commit 9fc2922794ffaae48e0a7c536e530ea2e0d46cf3 adds a loop to the nginx > service that checks for /var/run/nginx/pid. Unfortunately, on berlin > that loop never ends because the file is not created (on berlin we use a > =E2=80=9Chand-written=E2=80=9D nginx config file that lacks a =E2=80=9Cpi= d=E2=80=9D directive; see > guix-maintenance.git.) > > I think there are two things to address: > > 1. Don=E2=80=99t look for a PID file when passed a hand-written config = file; > > 2. Make sure the loop always terminates, similar to what > =E2=80=98make-forkexec-constructor=E2=80=99 does. > > The patch below fixes that. The second patch fixes the =E2=80=98stop=E2= =80=99 > procedure. > > Thoughts? > > Ludo=E2=80=99. > > From c9daf228a69c24cff6ba5508a3b67ebe3c702a2b Mon Sep 17 00:00:00 2001 > From: =3D?UTF-8?q?Ludovic=3D20Court=3DC3=3DA8s?=3D > Date: Sat, 8 Sep 2018 18:48:48 +0200 > Subject: [PATCH 1/2] services: nginx: Don't read PID file when passed a c= ustom > config file. > > Fixes . > > * gnu/services/web.scm (nginx-shepherd-service): Check whether FILE is > true and don't read the PID file if it is; use 'read-pid-file' instead > of a potentially endless loop. > --- > gnu/services/web.scm | 14 ++++++-------- > 1 file changed, 6 insertions(+), 8 deletions(-) > > diff --git a/gnu/services/web.scm b/gnu/services/web.scm > index 3778efd04..1c993b29f 100644 > --- a/gnu/services/web.scm > +++ b/gnu/services/web.scm > @@ -610,14 +610,12 @@ of index files." > (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 re= ad))) > - ;; it could be # > - (if (integer? pid) pid (loop 1))) > - (loop 1))))))))) > + ;; When FILE is true, we cannot be sure that PID-FIL= E will > + ;; be created, so assume it won't show up. When FIL= E is > + ;; false, read PID-FILE. > + #$(if file > + #~#t > + #~(read-pid-file #$pid-file)))))))) >=20=20 > ;; TODO: Add 'reload' action. > (list (shepherd-service > --=20 > 2.18.0 > > From 211a820dbd37926f07f9245ab42cbaf6fb0264bb Mon Sep 17 00:00:00 2001 > From: =3D?UTF-8?q?Ludovic=3D20Court=3DC3=3DA8s?=3D > Date: Sat, 8 Sep 2018 18:50:55 +0200 > Subject: [PATCH 2/2] services: nginx: 'stop' returns #f. > > Previously we'd return #t, which the Shepherd would consider a failure > to stop the service. > > * gnu/services/web.scm (nginx-shepherd-service): In 'nginx-action', > return #f when stopping the service. > --- > gnu/services/web.scm | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gnu/services/web.scm b/gnu/services/web.scm > index 1c993b29f..df82a6de6 100644 > --- a/gnu/services/web.scm > +++ b/gnu/services/web.scm > @@ -608,7 +608,7 @@ of index files." > (default-nginx-config config)) > #$@args) > (match '#$args > - (("-s" . _) #t) > + (("-s" . _) #f) > (_ > ;; When FILE is true, we cannot be sure that PID-FIL= E will > ;; be created, so assume it won't show up. When FIL= E is