unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: "Clément Lassieur" <clement@lassieur.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 29992@debbugs.gnu.org
Subject: bug#29992: [PATCH] services: postgresql: Use pg_ctl to start and stop postgres.
Date: Wed, 24 Jan 2018 18:16:17 +0100	[thread overview]
Message-ID: <87k1w79nz2.fsf@lassieur.org> (raw)
In-Reply-To: <87d11zxpqp.fsf@gnu.org>

Ludovic Courtès <ludo@gnu.org> writes:

> Clément Lassieur <clement@lassieur.org> skribis:
>
>> Fixes <https://bugs.gnu.org/29992>.
>>
>> * 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---

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

  reply	other threads:[~2018-01-24 17:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-05 15:32 bug#29992: 'postgres' service doesn't stop Clément Lassieur
2018-01-08 10:59 ` Ludovic Courtès
2018-01-08 11:33   ` Clément Lassieur
2018-01-08 21:55   ` Alex Kost
2018-01-12  9:46     ` Catonano
2018-01-12 21:42       ` Danny Milosavljevic
2018-01-24  2:20   ` bug#29992: [PATCH] services: postgresql: Use pg_ctl to start and stop postgres Clément Lassieur
2018-01-24 15:04     ` Ludovic Courtès
2018-01-24 17:16       ` Clément Lassieur [this message]
2018-01-25 13:13         ` Clément Lassieur
2018-01-25 13:20       ` Clément Lassieur
2018-01-25 14:22         ` Ludovic Courtès
2018-01-25 14:56           ` Clément Lassieur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k1w79nz2.fsf@lassieur.org \
    --to=clement@lassieur.org \
    --cc=29992@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).