diff options
Diffstat (limited to 'guix/forge')
-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 |