From: "Clément Lassieur" <clement@lassieur.org>
To: 29992@debbugs.gnu.org
Subject: bug#29992: [PATCH] services: postgresql: Use pg_ctl to start and stop postgres.
Date: Thu, 25 Jan 2018 14:20:02 +0100 [thread overview]
Message-ID: <20180125132002.12953-1-clement@lassieur.org> (raw)
In-Reply-To: <87d11zxpqp.fsf@gnu.org>
Fixes <https://bugs.gnu.org/29992>.
* gnu/services/databases.scm (postgresql-shepherd-service): Replace
make-forkexec-constructor and make-kill-destructor with pg_ctl.
---
gnu/services/databases.scm | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index 6a01cb1ce..b34a67aa9 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)
--
2.16.1
next prev parent reply other threads:[~2018-01-25 13:21 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
2018-01-25 13:13 ` Clément Lassieur
2018-01-25 13:20 ` Clément Lassieur [this message]
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=20180125132002.12953-1-clement@lassieur.org \
--to=clement@lassieur.org \
--cc=29992@debbugs.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).