aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2024-12-17 20:47:29 +0000
committerChristopher Baines <mail@cbaines.net>2024-12-18 10:35:51 +0000
commitae61d466eb45ebc36f97bb06ccd7160642013288 (patch)
treeb00ceadabde34bf915bf8847db2b527eb00fa403
parentc22fc744b49ef8ef30e5ca4664af16c1893cc81f (diff)
downloadguix-ae61d466eb45ebc36f97bb06ccd7160642013288.tar
guix-ae61d466eb45ebc36f97bb06ccd7160642013288.tar.gz
WIP
Change-Id: Ic84d159be3c961e3304e614b59cc78820ad0e4d2
-rw-r--r--gnu/services/web.scm80
1 files changed, 55 insertions, 25 deletions
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 3997fe2ab8..e8b1657a2a 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -1790,6 +1790,25 @@ ENABLE_XMLRPC = " #$(if enable-xmlrpc? "True" "False") "
FORCE_HTTPS_LINKS = " #$(if force-https-links? "True" "False") "
+LOGGING = {
+ 'version': 1,
+ 'disable_existing_loggers': False,
+ 'handlers': {
+ 'file': {
+ 'level': 'DEBUG',
+ 'class': 'logging.FileHandler',
+ 'filename': '/var/log/patchwork/debug.log',
+ },
+ },
+ 'loggers': {
+ 'django': {
+ 'handlers': ['file'],
+ 'level': 'DEBUG',
+ 'propagate': True,
+ },
+ },
+}
+
DATABASES = {
'default': {
" #$(match database-configuration
@@ -1871,27 +1890,23 @@ WSGIPassAuthorization On
(patchwork-virtualhost patchwork-configuration)))
(define (patchwork-django-admin-gexp patchwork settings-module)
- #~(lambda command
- (let ((pid (primitive-fork))
- (user (getpwnam "httpd")))
+ #~(lambda (_ . command)
+ (let ((pid (primitive-fork)))
(if (eq? pid 0)
- (dynamic-wind
- (const #t)
- (lambda ()
- (setgid (passwd:gid user))
- (setuid (passwd:uid user))
-
- (setenv "DJANGO_SETTINGS_MODULE" "guix.patchwork.settings")
- (setenv "PYTHONPATH" #$settings-module)
- (primitive-exit
- (if (zero?
- (apply system*
- #$(file-append patchwork "/bin/patchwork-admin")
- command))
- 0
- 1)))
- (lambda ()
- (primitive-exit 1)))
+ (let ((user (getpwnam "httpd")))
+ (setgid (passwd:gid user))
+ (setuid (passwd:uid user))
+
+ (let ((pid
+ (spawn
+ #$(file-append patchwork "/bin/patchwork-admin")
+ (cons #$(file-append patchwork "/bin/patchwork-admin")
+ command)
+ #:environment
+ `("DJANGO_SETTINGS_MODULE=guix.patchwork.settings"
+ ,(string-append "PYTHONPATH=" #$settings-module)
+ ,@(environ)))))
+ (waitpid pid)))
(zero? (cdr (waitpid pid)))))))
(define (patchwork-django-admin-action patchwork settings-module)
@@ -1919,7 +1934,8 @@ WSGIPassAuthorization On
(mkdir-p (dirname secret-key-file))
(call-with-output-file secret-key-file
(lambda (port)
- (display (random-token 30 'very-strong) port)))
+ (display ((@ (gcrypt random) random-token)
+ 30 'very-strong) port)))
(let* ((pw (getpwnam "httpd"))
(uid (passwd:uid pw))
(gid (passwd:gid pw)))
@@ -1933,19 +1949,18 @@ WSGIPassAuthorization On
(string-append (package-name patchwork)
"-setup"))))
(start
- #~(lambda ()
+ #~(lambda ()
(define run-django-admin-command
#$(patchwork-django-admin-gexp patchwork
settings-module))
#$secret-key-file-creation-gexp
- (run-django-admin-command "migrate")))
- (stop #~(const #f))
+ (run-django-admin-command #f "migrate")))
+ (one-shot? #t)
(actions
(list (patchwork-django-admin-action patchwork
settings-module)))
- (respawn? #f)
(documentation "Setup Patchwork."))))))
(define patchwork-getmail-configs
@@ -1981,6 +1996,19 @@ WSGIPassAuthorization On
(list "DJANGO_SETTINGS_MODULE=guix.patchwork.settings"
#~(string-append "PYTHONPATH=" #$settings-module))))))))
+(define (patchwork-activation config)
+ #~(begin
+ (use-modules (guix build utils))
+
+ (define %user
+ (getpw "httpd"))
+
+ (mkdir-p "/var/log/patchwork")
+
+ (chown "/var/log/patchwork"
+ (passwd:uid %user)
+ (passwd:gid %user))))
+
(define patchwork-service-type
(service-type
(name 'patchwork-setup)
@@ -1989,6 +2017,8 @@ WSGIPassAuthorization On
patchwork-httpd-configuration)
(service-extension shepherd-root-service-type
patchwork-shepherd-services)
+ (service-extension activation-service-type
+ patchwork-activation)
(service-extension getmail-service-type
patchwork-getmail-configs)))
(description