diff options
author | Christopher Baines <mail@cbaines.net> | 2024-11-05 21:11:02 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2024-11-08 12:52:18 +0000 |
commit | c58ee6726b5f4d8a209d1af85e393edd0ca4d02a (patch) | |
tree | 7db536427ad939f7eb0686fe211588fc773d7406 | |
parent | 717b861d31b62282f394672f95451be61dc62bcd (diff) | |
download | data-service-c58ee6726b5f4d8a209d1af85e393edd0ca4d02a.tar data-service-c58ee6726b5f4d8a209d1af85e393edd0ca4d02a.tar.gz |
Fix starting with an empty database
-rw-r--r-- | guix-data-service/substitutes.scm | 9 | ||||
-rw-r--r-- | guix-data-service/web/server.scm | 3 | ||||
-rw-r--r-- | scripts/guix-data-service.in | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/guix-data-service/substitutes.scm b/guix-data-service/substitutes.scm index c7a45dc..3603521 100644 --- a/guix-data-service/substitutes.scm +++ b/guix-data-service/substitutes.scm @@ -19,6 +19,7 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) #:use-module (ice-9 match) + #:use-module (ice-9 atomic) #:use-module (ice-9 threads) #:use-module (fibers) #:use-module (fibers channels) @@ -149,7 +150,7 @@ (lambda (channel) (put-message channel (cons build-server-id build-ids))))))) -(define (start-substitute-query-threads) +(define (start-substitute-query-threads startup-completed?) (define channel (make-channel)) @@ -162,6 +163,9 @@ (set-thread-name "request substitute query")) (const #t)) + (while (not (atomic-box-ref startup-completed?)) + (sleep 1)) + (while #t (with-exception-handler (lambda (exn) @@ -208,6 +212,9 @@ (set-thread-name "bulk substitute query")) (const #t)) + (while (not (atomic-box-ref startup-completed?)) + (sleep 1)) + (while #t (with-exception-handler (lambda (exn) diff --git a/guix-data-service/web/server.scm b/guix-data-service/web/server.scm index 77db774..4e08161 100644 --- a/guix-data-service/web/server.scm +++ b/guix-data-service/web/server.scm @@ -260,6 +260,9 @@ port. Also, the port used can be changed by passing the --port option.\n" (spawn-fiber (lambda () + (while (not (check-startup-completed startup-completed)) + (sleep 1)) + (with-resource-from-pool (background-connection-pool) conn (backfill-guix-revision-package-derivation-distribution-counts conn))) diff --git a/scripts/guix-data-service.in b/scripts/guix-data-service.in index 8a124ee..172838f 100644 --- a/scripts/guix-data-service.in +++ b/scripts/guix-data-service.in @@ -197,7 +197,7 @@ (lambda (port) (simple-format port "~A\n" (getpid))))) - (start-substitute-query-threads) + (start-substitute-query-threads startup-completed) (call-with-new-thread (lambda () |