[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 24/24: shepherd: Gracefully handle failure to open the socket
From: |
Ludovic Courtès |
Subject: |
[shepherd] 24/24: shepherd: Gracefully handle failure to open the socket. |
Date: |
Mon, 28 Mar 2022 17:24:48 -0400 (EDT) |
civodul pushed a commit to branch wip-fibers
in repository shepherd.
commit 8664372dff85059c8958bc112e91ce29e3dabe67
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Mar 28 23:10:03 2022 +0200
shepherd: Gracefully handle failure to open the socket.
Previously 'shepherd' would just show a backtrace and hang because other
fibers would still be running.
* modules/shepherd.scm (call-with-server-socket): Catch 'system-error'
around 'open-server-socket' call.
---
modules/shepherd.scm | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index 63a0a2c..80ce642 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -72,7 +72,18 @@ delimited continuations and fibers."
(define (call-with-server-socket file-name proc)
"Call PROC, passing it a listening socket at FILE-NAME and deleting the
socket file at FILE-NAME upon exit of PROC. Return the values of PROC."
- (let ((sock (open-server-socket file-name)))
+ (let ((sock (catch 'system-error
+ (lambda ()
+ (open-server-socket file-name))
+ (lambda args
+ (match args
+ ((key proc . _)
+ (report-error (l10n "while opening socket '~a': ~a: ~a~%")
+ file-name proc
+ (strerror (system-error-errno args)))
+ ;; Stop services that were started from the config file
+ ;; and quit.
+ (stop 'root)))))))
(unwind-protect (proc sock)
(begin
(close sock)
- [shepherd] 22/24: service: 'make-inetd-constructor' lets the caller specify socket ownership., (continued)
- [shepherd] 22/24: service: 'make-inetd-constructor' lets the caller specify socket ownership., Ludovic Courtès, 2022/03/28
- [shepherd] 06/24: service: 'read-pid-file' no longer blocks., Ludovic Courtès, 2022/03/28
- [shepherd] 09/24: service: 'make-forkexec-constructor' spawns a logging fiber., Ludovic Courtès, 2022/03/28
- [shepherd] 16/24: service: Add systemd constructor and destructor., Ludovic Courtès, 2022/03/28
- [shepherd] 11/24: support: 'l10n' accepts plural forms., Ludovic Courtès, 2022/03/28
- [shepherd] 01/24: shepherd: Factorize out the main loop., Ludovic Courtès, 2022/03/28
- [shepherd] 04/24: build: Capture the source and object directories of Fibers., Ludovic Courtès, 2022/03/28
- [shepherd] 07/24: service: 'read-pid-file' uses (@ (guile) sleep) when it's not suspendable., Ludovic Courtès, 2022/03/28
- [shepherd] 21/24: service: Add #:max-connections to 'make-inetd-constructor'., Ludovic Courtès, 2022/03/28
- [shepherd] 23/24: shepherd: Do not change to the client directory when executing a command., Ludovic Courtès, 2022/03/28
- [shepherd] 24/24: shepherd: Gracefully handle failure to open the socket.,
Ludovic Courtès <=