aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-06-09 13:27:12 +0100
committerChristopher Baines <mail@cbaines.net>2023-06-09 16:11:06 +0100
commit29d49ba31adfe4703c96572f31b1a9c4c3227dc3 (patch)
tree449ff846072bb355c1f8b04e9046e7db6fd17651 /scripts
parent5c9ec28cb5d248bb3e3bbe6e68d67de910e03b5b (diff)
downloaddata-service-29d49ba31adfe4703c96572f31b1a9c4c3227dc3.tar
data-service-29d49ba31adfe4703c96572f31b1a9c4c3227dc3.tar.gz
Detach the database setup from the main guix-data-service process
This will allow restarting them independently, leaving it up to the operator to ensure that all processes are compatible.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/guix-data-service-process-jobs.in2
-rw-r--r--scripts/guix-data-service.in52
2 files changed, 4 insertions, 50 deletions
diff --git a/scripts/guix-data-service-process-jobs.in b/scripts/guix-data-service-process-jobs.in
index fb0385e..6ad1ec9 100644
--- a/scripts/guix-data-service-process-jobs.in
+++ b/scripts/guix-data-service-process-jobs.in
@@ -65,6 +65,8 @@
%default-options))
(let ((opts (parse-options (cdr (program-arguments)))))
+ (run-sqitch)
+
(with-postgresql-connection
"process-jobs"
(lambda (conn)
diff --git a/scripts/guix-data-service.in b/scripts/guix-data-service.in
index 1398aa0..6a41413 100644
--- a/scripts/guix-data-service.in
+++ b/scripts/guix-data-service.in
@@ -234,57 +234,9 @@
(simple-format port "~A\n" (getpid)))))
(when (assoc-ref opts 'update-database)
- (let ((command
- (list (%config 'sqitch)
- "deploy"
- "--db-client" (%config 'sqitch-psql)
- ;; For some reason, sqitch behaves differently when the
- ;; guix-data-service is packaged, and when it's not, so try
- ;; and hack around this here.
- "--chdir" (let ((base (dirname (%config 'sqitch-plan))))
- (if (string-prefix? "/gnu" (%config 'sqitch-plan))
- base
- (dirname base)))
- "--plan-file" (%config 'sqitch-plan)
- "--mode" "change" ; this helps when migrations don't
- ; have the revert bit implemented
- (let* ((database-config (get-database-config))
- (params (string-join
- (map
- (match-lambda
- ((key . val)
- (string-append key "=" val)))
- (filter
- (match-lambda
- ((key . _)
- (not (member key '("user"
- "host"
- "dbname")))))
- database-config))
- "&")))
- (string-append "db:pg://"
- (assoc-ref database-config "user")
- "@"
- (if (string=? (assoc-ref database-config "host")
- "localhost")
- "" ; This means the unix socket
- ; connection will be used
- (assoc-ref database-config "host"))
- "/"
- (assoc-ref database-config "dbname")
- (if (string-null? params)
- ""
- "?")
- params)))))
- (simple-format #t "running command: ~A\n"
- (string-join command))
- (unless (zero? (apply system* command))
- (simple-format
- (current-error-port)
- "error: sqitch command failed\n")
- (exit 1))
+ (run-sqitch)
- (atomic-box-set! startup-completed #t)))
+ (atomic-box-set! startup-completed #t))
(call-with-new-thread
(lambda ()