From c7cb771cf40d779cbce062c029ee51fbd7de181b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 28 Mar 2026 15:22:05 +0100 Subject: services: nginx: Fix ‘stop’ in cases where a custom config file is passed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, when the ‘file’ field of ‘nginx-configuration’ was true, the PID file would be unknown; thus, the ‘start’ method would return #t and the ‘stop’ method would eventually fail with a type error because it would receive #t instead of a process. This fixes it by changing ‘stop’ to invoke “nginx -s stop” when the service’s value is not a process. * gnu/services/web.scm (nginx-shepherd-service): In ‘stop’, change to invoke “nginx -s stop” when ‘value’ is not a process. Fixes: guix/guix#7061 Reported-by: Dan Littlewood Change-Id: I20ff065ecd2c64e5fc98f59c25d91b300bc7b4cd Signed-off-by: Ludovic Courtès Merges: #7543 --- gnu/services/web.scm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 2056e0cca15..948d8064c6a 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 David Thompson -;;; Copyright © 2015-2023, 2025 Ludovic Courtès +;;; Copyright © 2015-2023, 2025-2026 Ludovic Courtès ;;; Copyright © 2016 Nikita ;;; Copyright © 2016, 2017, 2018 Julien Lepiller ;;; Copyright © 2017, 2018, 2019 Christopher Baines @@ -987,11 +987,15 @@ of index files." (modules `((ice-9 match) ,@%default-modules)) (start (nginx-action "-p" run-directory)) - - ;; Instead of invoking "nginx -s stop", use - ;; 'make-kill-destructor', which waits for the main process to - ;; actually terminate. - (stop #~(make-kill-destructor)) + (stop #~(lambda (value) + ;; When the PID is known, use 'terminate-process', which + ;; waits for the main process to actually terminate. + ;; When FILE is true, there's potentially no PID file + ;; and thus the PID is not known; in that case, invoke + ;; "nginx -s stop". + (if (process? value) + (terminate-process (process-id value) SIGTERM) + (#$(nginx-action "stop"))))) (actions (list -- cgit v1.3