From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Cl=C3=A9ment?= Lassieur Subject: bug#29992: [PATCH] services: postgresql: Use pg_ctl to start and stop postgres. Date: Wed, 24 Jan 2018 03:20:37 +0100 Message-ID: <20180124022037.29376-1-clement@lassieur.org> References: <87373ghaza.fsf@gnu.org> Return-path: Received: from eggs.gnu.org ([208.118.235.92]:38330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeAhq-0001tD-FG for bug-guix@gnu.org; Tue, 23 Jan 2018 21:22:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeAhO-0001BC-Od for bug-guix@gnu.org; Tue, 23 Jan 2018 21:22:30 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:60530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eeAhO-0001AK-GF for bug-guix@gnu.org; Tue, 23 Jan 2018 21:22:02 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87373ghaza.fsf@gnu.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: 29992@debbugs.gnu.org Fixes . * gnu/services/databases.scm (postgresql-shepherd-service): Replace make-forkexec-constructor and make-kill-destructor with pg_ctl. --- gnu/services/databases.scm | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index 6a01cb1ce..42f2315d5 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -147,26 +147,33 @@ host all all ::1/128 trust")) (define postgresql-shepherd-service (match-lambda (($ 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"))) + (setgid (passwd:gid user)) + (setuid (passwd:uid user)) + (system + (format #f "~a -D ~a -o '--config-file=~a -p ~d' ~a" + pg_ctl #$data-directory #$config-file #$port + 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) -- 2.16.0