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.
This commit is contained in:
Christopher Baines 2019-06-11 07:40:26 +01:00
parent cf5dace846
commit bd292d6f57

View file

@ -44,6 +44,11 @@
(alist-cons 'listen-repl port (alist-cons 'listen-repl port
(alist-delete 'listen-repl result)) (alist-delete 'listen-repl result))
(error "invalid REPL server port" arg))))) (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 (option '("update-database") #f #f
(lambda (opt name _ result) (lambda (opt name _ result)
(alist-cons 'update-database #t result))))) (alist-cons 'update-database #t result)))))
@ -86,6 +91,12 @@
(simple-format (simple-format
(current-error-port) (current-error-port)
"error: sqitch command failed\n") "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) (start-guix-data-service-web-server 8765)