aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Lassieur <clement@lassieur.org>2018-08-13 20:37:09 +0200
committerClément Lassieur <clement@lassieur.org>2018-08-13 23:44:26 +0200
commitef2dda8edb2b78cf6a2ffcdac138421b2553aec8 (patch)
treeddd5fc30a4094ecf91279452fb00b7d0cad0dd68
parentff6436307ef5e5e0f090758f839215e5296181eb (diff)
downloadpatches-ef2dda8edb2b78cf6a2ffcdac138421b2553aec8.tar
patches-ef2dda8edb2b78cf6a2ffcdac138421b2553aec8.tar.gz
services: postgresql: Get the Shepherd to respawn PostgreSQL.
* gnu/services/databases.scm (postgresql-shepherd-service): Change 'start' to return the PID.
-rw-r--r--gnu/services/databases.scm9
1 files changed, 8 insertions, 1 deletions
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index 8ae248ebe4..aff78a0566 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -221,13 +221,20 @@ host all all ::1/128 trust"))
(setuid (passwd:uid user))
(execl pg_ctl pg_ctl "-D" #$data-directory "-o" options
mode)))))))
+ (pid-file (in-vicinity data-directory "postmaster.pid"))
(action (lambda args
#~(lambda _
- (invoke #$pg_ctl-wrapper #$@args)))))
+ (invoke #$pg_ctl-wrapper #$@args)
+ (match '#$args
+ (("start")
+ (call-with-input-file #$pid-file read))
+ (_ #t))))))
(list (shepherd-service
(provision '(postgres))
(documentation "Run the PostgreSQL daemon.")
(requirement '(user-processes loopback syslogd))
+ (modules `((ice-9 match)
+ ,@%default-modules))
(start (action "start"))
(stop (action "stop"))))))))