aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-06-11 07:40:26 +0100
committerChristopher Baines <mail@cbaines.net>2019-06-11 07:40:26 +0100
commitbd292d6f570ef76fd2bcd10050915e2c8f811078 (patch)
tree69a0fe3a0f9e99ccdd3e712833b1fe96149c210c /scripts
parentcf5dace846b2f486a386b940c5871f7068889181 (diff)
downloaddata-service-bd292d6f570ef76fd2bcd10050915e2c8f811078.tar
data-service-bd292d6f570ef76fd2bcd10050915e2c8f811078.tar.gz
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.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/guix-data-service.in13
1 files changed, 12 insertions, 1 deletions
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)