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: Thu, 25 Jan 2018 14:13:08 +0100 Message-ID: <87inbq9j4r.fsf@lassieur.org> References: <87373ghaza.fsf@gnu.org> <20180124022037.29376-1-clement@lassieur.org> <87d11zxpqp.fsf@gnu.org> <87k1w79nz2.fsf@lassieur.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eehM0-0000Va-BK for bug-guix@gnu.org; Thu, 25 Jan 2018 08:14:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eehLv-0006K8-BL for bug-guix@gnu.org; Thu, 25 Jan 2018 08:14:08 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:33959) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eehLv-0006K2-8G for bug-guix@gnu.org; Thu, 25 Jan 2018 08:14:03 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-reply-to: <87k1w79nz2.fsf@lassieur.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: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 29992@debbugs.gnu.org Clément Lassieur writes: > Ludovic Courtès writes: > >> Clément Lassieur skribis: >> >>> Fixes . >>> >>> * gnu/services/databases.scm (postgresql-shepherd-service): Replace >>> make-forkexec-constructor and make-kill-destructor with pg_ctl. >> >> [...] >> >>> + (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)))))))) >> >> I think we should use ‘execl’ here instead of ‘system’ so that (1) the >> exit code is correct, and (2) we don’t go through /bin/sh. > > Hi Ludovic, thank you for the review. > > How do you pass single quotes as an ‘execl’ argument? > > https://www.postgresql.org/docs/9.3/static/app-pg-ctl.html says: > --8<---------------cut here---------------start------------->8--- > -o options > Specifies options to be passed directly to the postgres command. > The options should usually be surrounded by single or double quotes > to ensure that they are passed through as a group. > --8<---------------cut here---------------end--------------->8--- Oh I understood this. I'll do a new patch. > Also, I don't understand how the exit code matters since Guile scripts > seem to always return 0, no matter if the last return value is true or > false. > > Clément