diff options
author | Mark H Weaver <mhw@netris.org> | 2018-01-26 00:15:26 -0500 |
---|---|---|
committer | Mark H Weaver <mhw@netris.org> | 2018-01-26 00:15:26 -0500 |
commit | b89d8a4271c8ef02c9b1e51a2c86341cdc09c760 (patch) | |
tree | f8e763584ac99d810135956cb09511434a703821 /gnu/services | |
parent | 7bf0170e9fbcb08f9edb875dc08e27584826a1c2 (diff) | |
parent | a81f7eb858bf7e320d4dccde183d303247b6d47a (diff) | |
download | patches-b89d8a4271c8ef02c9b1e51a2c86341cdc09c760.tar patches-b89d8a4271c8ef02c9b1e51a2c86341cdc09c760.tar.gz |
Merge branch 'master' into core-updates
Diffstat (limited to 'gnu/services')
-rw-r--r-- | gnu/services/databases.scm | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index 6a01cb1ce6..b34a67aa95 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2016 Leo Famulari <leo@famulari.name> ;;; Copyright © 2017 Christopher Baines <mail@cbaines.net> +;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -147,26 +148,33 @@ host all all ::1/128 trust")) (define postgresql-shepherd-service (match-lambda (($ <postgresql-configuration> postgresql port locale config-file data-directory) - (let ((start-script - ;; Wrapper script that switches to the 'postgres' user before - ;; launching daemon. - (program-file "start-postgres" - #~(let ((user (getpwnam "postgres")) - (postgres (string-append #$postgresql - "/bin/postgres"))) - (setgid (passwd:gid user)) - (setuid (passwd:uid user)) - (system* postgres - (string-append "--config-file=" - #$config-file) - "-p" (number->string #$port) - "-D" #$data-directory))))) + (let* ((pg_ctl-wrapper + ;; Wrapper script that switches to the 'postgres' user before + ;; launching daemon. + (program-file + "pg_ctl-wrapper" + #~(begin + (use-modules (ice-9 match) + (ice-9 format)) + (match (command-line) + ((_ mode) + (let ((user (getpwnam "postgres")) + (pg_ctl #$(file-append postgresql "/bin/pg_ctl")) + (options (format #f "--config-file=~a -p ~d" + #$config-file #$port))) + (setgid (passwd:gid user)) + (setuid (passwd:uid user)) + (execl pg_ctl pg_ctl "-D" #$data-directory "-o" options + mode))))))) + (action (lambda args + #~(lambda _ + (invoke #$pg_ctl-wrapper #$@args))))) (list (shepherd-service (provision '(postgres)) (documentation "Run the PostgreSQL daemon.") (requirement '(user-processes loopback syslogd)) - (start #~(make-forkexec-constructor #$start-script)) - (stop #~(make-kill-destructor)))))))) + (start (action "start")) + (stop (action "stop")))))))) (define postgresql-service-type (service-type (name 'postgresql) |