From 962364bcb5aca3bb639c48b8e098f54c7e458472 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 29 Aug 2023 15:10:03 +0100 Subject: Exit when the server fails to start To avoid the process half working. --- .../agent-messaging/http/server.scm | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'guix-build-coordinator/agent-messaging') diff --git a/guix-build-coordinator/agent-messaging/http/server.scm b/guix-build-coordinator/agent-messaging/http/server.scm index aaa88cb..e2e752c 100644 --- a/guix-build-coordinator/agent-messaging/http/server.scm +++ b/guix-build-coordinator/agent-messaging/http/server.scm @@ -160,7 +160,12 @@ INTERVAL (a time-duration object), otherwise does nothing and returns #f." (length (all-threads))) (call-with-delay-logging port-metrics-updater)) - (call-with-error-handling + (with-exception-handler + (lambda (exn) + (simple-format + (current-error-port) + "exception when starting: ~A\n" exn) + (primitive-exit 1)) (lambda () (run-server/patched (lambda (request body) @@ -182,19 +187,7 @@ INTERVAL (a time-duration object), otherwise does nothing and returns #f." update-managed-metrics!))) #:host host #:port port)) - #:on-error 'backtrace - #:post-error (lambda (key . args) - (when (eq? key 'system-error) - (match args - (("bind" "~A" ("Address already in use") _) - (simple-format - (current-error-port) - "\n -error: guix-build-coordinator could not start, as it could not bind to port ~A - -Check if it's already running, or whether another process is using that -port. Also, the port used can be changed by passing the --port option.\n" - port))))))) + #:unwind? #t)) (define* (render-json json #:key (extra-headers '()) (code 200)) -- cgit v1.2.3