diff options
author | Arun Isaac | 2023-12-22 12:17:29 +0000 |
---|---|---|
committer | Arun Isaac | 2023-12-22 12:17:29 +0000 |
commit | 2e15351f07522aa88415351c2d919b3329dd4a20 (patch) | |
tree | 66f55e44607161589e88333f7aa8aedc6adfc5fc | |
parent | 74d1c253174504b4c41b4423298398d8e6d07ac3 (diff) | |
download | guix-forge-2e15351f07522aa88415351c2d919b3329dd4a20.tar.gz guix-forge-2e15351f07522aa88415351c2d919b3329dd4a20.tar.lz guix-forge-2e15351f07522aa88415351c2d919b3329dd4a20.zip |
gunicorn: Provision app-specific symbol.
Provisioning the 'gunicorn symbol is problematic when there are
multiple gunicorn apps running.
* guix/forge/gunicorn.scm (gunicorn-shepherd-services): Provision
app-specific symbol.
-rw-r--r-- | guix/forge/gunicorn.scm | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/guix/forge/gunicorn.scm b/guix/forge/gunicorn.scm index 215bdbd..9f5b2b2 100644 --- a/guix/forge/gunicorn.scm +++ b/guix/forge/gunicorn.scm @@ -135,80 +135,80 @@ (define (gunicorn-shepherd-services config) (map (lambda (app) - (shepherd-service - (documentation (string-append "Run gunicorn for app " - (gunicorn-app-name app) - ".")) - (provision '(gunicorn)) - (requirement '(networking)) - (modules '((guix search-paths) - (ice-9 match))) - (start - (let* ((name (string-append "gunicorn-" (gunicorn-app-name app))) - (app-manifest (packages->manifest - ;; Using python-minimal in the - ;; manifest creates collisions with - ;; the python in the app package. - (list python - (gunicorn-app-package app)))) - (app-profile (profile - (content app-manifest) - (allow-collisions? #t)))) - (with-imported-modules (source-module-closure '((guix search-paths))) - #~(make-forkexec-constructor - (cons* #$(least-authority-wrapper - (file-append (gunicorn-configuration-package config) - "/bin/gunicorn") - #:name (string-append name "-pola-wrapper") - #:mappings (cons (file-system-mapping - ;; Mapping the app package - (source app-profile) - (target source)) - (append - ;; Mappings for Unix socket directories - (filter-map (lambda (socket) - (and (forge-unix-socket? socket) - (file-system-mapping - (source (dirname (forge-unix-socket-path socket))) - (target source) - (writable? #t)))) - (gunicorn-app-sockets app)) - ;; Additional mappings - (gunicorn-app-mappings app))) - #:preserved-environment-variables - (map search-path-specification-variable - (manifest-search-paths app-manifest)) - ;; TODO: If socket is a Unix socket, run in a - ;; network namespace. We can't do this yet due to - ;; https://yhetil.org/guix/m1ilknoi5r.fsf@fastmail.net/ - #:namespaces (delq 'net %namespaces)) - "--workers" #$(number->string (gunicorn-app-workers app)) - (list #$@(append (append-map (lambda (socket) - (list "--bind" - (socket->gunicorn-bind socket))) - (gunicorn-app-sockets app)) - (append-map (lambda (variable) - (list "--env" - #~(string-append #$(environment-variable-name variable) - "=" - #$(environment-variable-value variable)))) - (gunicorn-app-environment-variables app)) - (list (gunicorn-app-wsgi-app-module app))))) - #:user #$name - #:group #$name - #:environment-variables - (map (match-lambda - ((spec . value) - (string-append (search-path-specification-variable spec) - "=" - value))) - (evaluate-search-paths - (map sexp->search-path-specification - '#$(map search-path-specification->sexp - (manifest-search-paths app-manifest))) - (list #$app-profile))) - #:log-file #$(string-append "/var/log/" name ".log"))))) - (stop #~(make-kill-destructor)))) + (let ((name (string-append "gunicorn-" (gunicorn-app-name app)))) + (shepherd-service + (documentation (string-append "Run gunicorn for app " + (gunicorn-app-name app) + ".")) + (provision (list (string->symbol name))) + (requirement '(networking)) + (modules '((guix search-paths) + (ice-9 match))) + (start + (let* ((app-manifest (packages->manifest + ;; Using python-minimal in the + ;; manifest creates collisions with + ;; the python in the app package. + (list python + (gunicorn-app-package app)))) + (app-profile (profile + (content app-manifest) + (allow-collisions? #t)))) + (with-imported-modules (source-module-closure '((guix search-paths))) + #~(make-forkexec-constructor + (cons* #$(least-authority-wrapper + (file-append (gunicorn-configuration-package config) + "/bin/gunicorn") + #:name (string-append name "-pola-wrapper") + #:mappings (cons (file-system-mapping + ;; Mapping the app package + (source app-profile) + (target source)) + (append + ;; Mappings for Unix socket directories + (filter-map (lambda (socket) + (and (forge-unix-socket? socket) + (file-system-mapping + (source (dirname (forge-unix-socket-path socket))) + (target source) + (writable? #t)))) + (gunicorn-app-sockets app)) + ;; Additional mappings + (gunicorn-app-mappings app))) + #:preserved-environment-variables + (map search-path-specification-variable + (manifest-search-paths app-manifest)) + ;; TODO: If socket is a Unix socket, run in a + ;; network namespace. We can't do this yet due to + ;; https://yhetil.org/guix/m1ilknoi5r.fsf@fastmail.net/ + #:namespaces (delq 'net %namespaces)) + "--workers" #$(number->string (gunicorn-app-workers app)) + (list #$@(append (append-map (lambda (socket) + (list "--bind" + (socket->gunicorn-bind socket))) + (gunicorn-app-sockets app)) + (append-map (lambda (variable) + (list "--env" + #~(string-append #$(environment-variable-name variable) + "=" + #$(environment-variable-value variable)))) + (gunicorn-app-environment-variables app)) + (list (gunicorn-app-wsgi-app-module app))))) + #:user #$name + #:group #$name + #:environment-variables + (map (match-lambda + ((spec . value) + (string-append (search-path-specification-variable spec) + "=" + value))) + (evaluate-search-paths + (map sexp->search-path-specification + '#$(map search-path-specification->sexp + (manifest-search-paths app-manifest))) + (list #$app-profile))) + #:log-file #$(string-append "/var/log/" name ".log"))))) + (stop #~(make-kill-destructor))))) (gunicorn-configuration-apps config))) (define gunicorn-service-type |