diff options
Diffstat (limited to 'guix-data-service/web/server.scm')
-rw-r--r-- | guix-data-service/web/server.scm | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/guix-data-service/web/server.scm b/guix-data-service/web/server.scm index cc67624..4739dd5 100644 --- a/guix-data-service/web/server.scm +++ b/guix-data-service/web/server.scm @@ -101,6 +101,7 @@ (%guix-data-service-metrics-registry registry) (let ((finished? (make-condition)) + (priority-scheduler #f) (request-scheduler #f)) (call-with-sigint (lambda () @@ -112,6 +113,33 @@ (schedulers (cons current (scheduler-remote-peers current)))) + (set! priority-scheduler current) + + (for-each + (lambda (i sched) + (spawn-fiber + (lambda () + (catch 'system-error + (lambda () + (set-thread-name + (string-append "priority " (number->string i)))) + (const #t))) + sched)) + (iota (length schedulers)) + schedulers)) + + (wait finished?)) + #:hz 0 + #:parallelism 1))) + + (call-with-new-thread + (lambda () + (run-fibers + (lambda () + (let* ((current (current-scheduler)) + (schedulers + (cons current (scheduler-remote-peers current)))) + (set! request-scheduler current) (for-each @@ -151,6 +179,8 @@ (while (not request-scheduler) (sleep 0.1)) + (while (not priority-scheduler) + (sleep 0.1)) (let ((requests-metric (make-counter-metric registry "requests_total"))) @@ -179,7 +209,8 @@ port. Also, the port used can be changed by passing the --port option.\n" #:idle-seconds 30 #:destructor (lambda (conn) - (close-postgresql-connection conn "web")))) + (close-postgresql-connection conn "web")) + #:scheduler priority-scheduler)) (reserved-connection-pool (make-resource-pool @@ -192,7 +223,8 @@ port. Also, the port used can be changed by passing the --port option.\n" #:idle-seconds 600 #:destructor (lambda (conn) - (close-postgresql-connection conn "web-reserved")))) + (close-postgresql-connection conn "web-reserved")) + #:scheduler priority-scheduler)) (resource-pool-default-timeout 5)) |