diff mbox series

[bug#69269,v2] gnu: web: fcgiwrap: remove UNIX socket when service stopped.

Message ID 20240309092311.2085201-1-guix-devel-0brg6b@rdmp.org
State New
Headers show
Series [bug#69269,v2] gnu: web: fcgiwrap: remove UNIX socket when service stopped. | expand

Commit Message

Dale Mellor March 9, 2024, 9:23 a.m. UTC
From: Dale Mellor <blackhole@rdmp.org>

The generic kill destructor is used to terminate the process, but if it was
configured to use a UNIX socket, that socket gets left behind.  Subsequent
attempts to re-start the service then fail with a 'socket in use' error.  So
we perform extra duty in the stop action to clean up if necessary.

* gnu/services/web.scm: new logic in fcgiwrap-shephard-service.
---
 gnu/services/web.scm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

宋文武 March 10, 2024, 2:56 a.m. UTC | #1
Dale Mellor <guix-devel-0brg6b@rdmp.org> writes:

> From: Dale Mellor <blackhole@rdmp.org>
>
> The generic kill destructor is used to terminate the process, but if it was
> configured to use a UNIX socket, that socket gets left behind.  Subsequent
> attempts to re-start the service then fail with a 'socket in use' error.  So
> we perform extra duty in the stop action to clean up if necessary.

Hello, I have sent a patch to update fcgiwrap to a more maintained fork,
which have the needed socket clean logic itself.

Please give it a test, I think it's better than handling that in
shepherd.  Thanks!
diff mbox series

Patch

diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 05fd71f9949..877e15342b0 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -907,7 +907,14 @@  (define fcgiwrap-shepherd-service
                         "-s" #$socket)
                       #:user #$user #:group #$group
                       #:log-file "/var/log/fcgiwrap.log"))
-            (stop #~(make-kill-destructor)))))))
+            (stop #~(let ((mkd (make-kill-destructor)))
+                      (lambda x
+                        (apply mkd x)
+                        (when (string-prefix? "unix:" #$socket)
+                          (let ((socket (substring #$socket 5)))
+                            (when (access? socket F_OK)
+                              (delete-file socket))))
+                        #f))))))))
 
 (define fcgiwrap-activation
   (match-lambda