Skip to content
Snippets Groups Projects
Unverified Commit 2d3d5cc5 authored by Christopher Baines's avatar Christopher Baines Committed by Ludovic Courtès
Browse files

services: postgresql: Add port to configuration


* gnu/services/databases.scm (<postgresql-configuration>): Add port
  field.
  (postgresql-shepherd-service): Pass port to postgres.
  (postgresql-service): Add port default.

Signed-off-by: default avatarLudovic Courtès <ludo@gnu.org>
parent eee7878f
No related branches found
No related tags found
No related merge requests found
......@@ -10166,13 +10166,14 @@ Users need to be in the @code{lp} group to access the D-Bus service.
The @code{(gnu services databases)} module provides the following services.
 
@deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
[#:config-file] [#:data-directory ``/var/lib/postgresql/data'']
[#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
[#:port 5432]
Return a service that runs @var{postgresql}, the PostgreSQL database
server.
 
The PostgreSQL daemon loads its runtime configuration from
@var{config-file} and stores the database cluster in
@var{data-directory}.
@var{config-file}, stores the database cluster in @var{data-directory} and
listens on @var{port}.
@end deffn
 
@deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
......
......@@ -48,6 +48,8 @@ (define-record-type* <postgresql-configuration>
postgresql-configuration?
(postgresql postgresql-configuration-postgresql ;<package>
(default postgresql))
(port postgresql-configuration-port
(default 5432))
(config-file postgresql-configuration-file)
(data-directory postgresql-configuration-data-directory))
......@@ -80,7 +82,7 @@ (define %postgresql-accounts
(define postgresql-activation
(match-lambda
(($ <postgresql-configuration> postgresql config-file data-directory)
(($ <postgresql-configuration> postgresql port config-file data-directory)
#~(begin
(use-modules (guix build utils)
(ice-9 match))
......@@ -108,7 +110,7 @@ (define postgresql-activation
(define postgresql-shepherd-service
(match-lambda
(($ <postgresql-configuration> postgresql config-file data-directory)
(($ <postgresql-configuration> postgresql port config-file data-directory)
(let ((start-script
;; Wrapper script that switches to the 'postgres' user before
;; launching daemon.
......@@ -121,6 +123,7 @@ (define postgresql-shepherd-service
(system* postgres
(string-append "--config-file="
#$config-file)
"-p" (number->string #$port)
"-D" #$data-directory)))))
(list (shepherd-service
(provision '(postgres))
......@@ -140,6 +143,7 @@ (define postgresql-service-type
(const %postgresql-accounts))))))
(define* (postgresql-service #:key (postgresql postgresql)
(port 5432)
(config-file %default-postgres-config)
(data-directory "/var/lib/postgresql/data"))
"Return a service that runs @var{postgresql}, the PostgreSQL database server.
......@@ -149,6 +153,7 @@ (define* (postgresql-service #:key (postgresql postgresql)
(service postgresql-service-type
(postgresql-configuration
(postgresql postgresql)
(port port)
(config-file config-file)
(data-directory data-directory))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment