services: postgresql: Get the Shepherd to respawn PostgreSQL.

* gnu/services/databases.scm (postgresql-shepherd-service): Change 'start' to
return the PID.
This commit is contained in:
Clément Lassieur 2018-08-13 20:37:09 +02:00
parent ff6436307e
commit ef2dda8edb
No known key found for this signature in database
GPG key ID: 89F96D4808F359C7

View file

@ -221,13 +221,20 @@ (define postgresql-shepherd-service
(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"))))))))