[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#29992: [PATCH] services: postgresql: Use pg_ctl to start and stop po
From: |
Clément Lassieur |
Subject: |
bug#29992: [PATCH] services: postgresql: Use pg_ctl to start and stop postgres. |
Date: |
Thu, 25 Jan 2018 14:13:08 +0100 |
User-agent: |
mu4e 0.9.18; emacs 25.3.1 |
Clément Lassieur <address@hidden> writes:
> Ludovic Courtès <address@hidden> writes:
>
>> Clément Lassieur <address@hidden> 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---
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
- bug#29992: 'postgres' service doesn't stop, Clément Lassieur, 2018/01/05
- bug#29992: 'postgres' service doesn't stop, Ludovic Courtès, 2018/01/08
- bug#29992: [PATCH] services: postgresql: Use pg_ctl to start and stop postgres., Clément Lassieur, 2018/01/23
- bug#29992: [PATCH] services: postgresql: Use pg_ctl to start and stop postgres., Clément Lassieur, 2018/01/25
- bug#29992: [PATCH] services: postgresql: Use pg_ctl to start and stop postgres., Ludovic Courtès, 2018/01/25
- bug#29992: [PATCH] services: postgresql: Use pg_ctl to start and stop postgres., Clément Lassieur, 2018/01/25