From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Baines Subject: [PATCH 1/2] services: postgresql: Add port to configuration Date: Sun, 11 Dec 2016 21:13:00 +0000 Message-ID: <20161211211301.28403-1-mail@cbaines.net> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGBQi-0005NI-KJ for guix-devel@gnu.org; Sun, 11 Dec 2016 16:13:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGBQf-0007DG-Gl for guix-devel@gnu.org; Sun, 11 Dec 2016 16:13:08 -0500 Received: from mira.cbaines.net ([2a01:7e00::f03c:91ff:fe69:8da9]:37481) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGBQf-0007BJ-8f for guix-devel@gnu.org; Sun, 11 Dec 2016 16:13:05 -0500 Received: from localhost (88-104-161-202.dynamic.dsl.as9105.com [88.104.161.202]) by mira.cbaines.net (Postfix) with ESMTPSA id 38C6B13D8EA for ; Sun, 11 Dec 2016 21:13:02 +0000 (GMT) Received: from chris by localhost with local (Exim 4.88) (envelope-from ) id 1cGBQb-0007Om-Q4 for guix-devel@gnu.org; Sun, 11 Dec 2016 21:13:01 +0000 List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * gnu/services/postgresql.scm (): Add port field. (postgresql-shepherd-service): Pass port to postgres. (postgresql-service): Add port default. --- gnu/services/databases.scm | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index 1eed85542..3850ba502 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -48,6 +48,8 @@ postgresql-configuration? (postgresql postgresql-configuration-postgresql ; (default postgresql)) + (port postgresql-configuration-port + (default 5432)) (config-file postgresql-configuration-file) (data-directory postgresql-configuration-data-directory)) @@ -80,7 +82,7 @@ host all all ::1/128 trust")) (define postgresql-activation (match-lambda - (($ postgresql config-file data-directory) + (($ postgresql port config-file data-directory) #~(begin (use-modules (guix build utils) (ice-9 match)) @@ -108,20 +110,22 @@ host all all ::1/128 trust")) (define postgresql-shepherd-service (match-lambda - (($ postgresql 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) - "-D" #$data-directory))))) + (($ postgresql port config-file data-directory) + (let* ((string-port (number->string port)) + (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" #$string-port + "-D" #$data-directory))))) (list (shepherd-service (provision '(postgres)) (documentation "Run the PostgreSQL daemon.") @@ -140,6 +144,7 @@ host all all ::1/128 trust")) (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 +154,7 @@ and stores the database cluster in @var{data-directory}." (service postgresql-service-type (postgresql-configuration (postgresql postgresql) + (port port) (config-file config-file) (data-directory data-directory)))) -- 2.11.0