From bd292d6f570ef76fd2bcd10050915e2c8f811078 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 11 Jun 2019 07:40:26 +0100 Subject: Add an option to create a pid-file This'll help the a service manager (like the shepherd) know when the service is ready, which at the moment, means the database migrations have happened. --- scripts/guix-data-service.in | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/guix-data-service.in b/scripts/guix-data-service.in index 61e4e1c..5710266 100644 --- a/scripts/guix-data-service.in +++ b/scripts/guix-data-service.in @@ -44,6 +44,11 @@ (alist-cons 'listen-repl port (alist-delete 'listen-repl result)) (error "invalid REPL server port" arg))))) + (option '("pid-file") #t #f + (lambda (opt name arg result) + (alist-cons 'pid-file + arg + result))) (option '("update-database") #f #f (lambda (opt name _ result) (alist-cons 'update-database #t result))))) @@ -86,6 +91,12 @@ (simple-format (current-error-port) "error: sqitch command failed\n") - (exit 1))))) + (exit 1)))) + + (let ((pid-file (assq-ref opts 'pid-file))) + (when pid-file + (call-with-output-file pid-file + (lambda (port) + (simple-format port "~A\n" (getpid))))))) (start-guix-data-service-web-server 8765) -- cgit v1.2.3