From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 04 14:11:02 2018 Received: (at submit) by debbugs.gnu.org; 4 Mar 2018 19:11:02 +0000 Received: from localhost ([127.0.0.1]:44684 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esZ2E-0004GF-Kf for submit@debbugs.gnu.org; Sun, 04 Mar 2018 14:11:02 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50421) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esZ2D-0004Fk-5g for submit@debbugs.gnu.org; Sun, 04 Mar 2018 14:11:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1esZ27-0006xJ-6J for submit@debbugs.gnu.org; Sun, 04 Mar 2018 14:10:55 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:55605) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1esZ27-0006xE-2w for submit@debbugs.gnu.org; Sun, 04 Mar 2018 14:10:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1esZ24-0004dn-KH for guix-patches@gnu.org; Sun, 04 Mar 2018 14:10:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1esZ1z-0006ux-MM for guix-patches@gnu.org; Sun, 04 Mar 2018 14:10:52 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:51150 helo=mira.cbaines.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1esZ1z-0006uf-Fx for guix-patches@gnu.org; Sun, 04 Mar 2018 14:10:47 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id 7F52213D067; Sun, 4 Mar 2018 19:10:46 +0000 (GMT) Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 48C0113D064 for ; Sun, 4 Mar 2018 19:10:46 +0000 (GMT) Received: from giedi (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 011fef7c for ; Sun, 4 Mar 2018 19:10:45 +0000 (UTC) User-agent: mu4e 0.9.18; emacs 25.3.1 From: Christopher Baines To: guix-patches@gnu.org Subject: [PATCH 0/4] PostgreSQL service changes (add record type, and system test) Date: Sun, 04 Mar 2018 19:10:43 +0000 Message-ID: <87po4jpsgc.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --=-=-= Content-Type: text/plain I was mostly adding the system test, but also ended up reworking the service so that Shepherd knows about the PID file. Christopher Baines (4): services: Rework the PostgreSQL config file to use a record type. services: Use a external pid file for PostgreSQL. tests: databases: Add a system test for PostgreSQL. services: databases: Add postgresql-configuration record exports. gnu/services/databases.scm | 125 ++++++++++++++++++++++++++++++++++++--------- gnu/tests/databases.scm | 59 +++++++++++++++++++++ 2 files changed, 161 insertions(+), 23 deletions(-) --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlqcRLNfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9Xdb4BAAp3eLXoLOwFu1/Re5AnXXe7d37jP4W2b8H5Qqz9mOfjvjBySw7C87LxMi eFHEGGnI/H0nb2sPe5ij2CGSMEfhJdFqLtdvX7CwSOHR7UB2r6uEciz4B0ov/6+w j8zBzAYmGhz+UtnqUz1IX4HUdp8Y+9yFdx/C9D9pvPDIFSRIGfsab4AdwU+VcZ+H CT1KiSYZcgO9CWjLnX7BlLbuuCPxD7UpamW65YL0gIYdyculhwiZfDkQRvkyh1U+ cVLSJqH5Q9i17pSMiHcaRi1++T27M/uPbqmbHxEbez/a2hbmix3h9378a2XfVUtQ pKjMy0DuOzcx0EE2Iodo7VgxnBuQ+PNldPUEbV4eLiUxXIZQMEjg/JwYvyLPfpB+ ZAwQi5oQ6aoiqXzyUaSoNYvnttfA/OmzXHpfCFJ2xACHphUNTeiYwsp+0lJEedvP cwUXKrWK4u2anJK+dkgpC2N+YmG9mSjTl1rdmWe9/ZPqfUrFSY39VOPgS4wGVxkL soGIPqByd7AAigZlOAGusFlBA14zVcNDhpcHlrf11t/meupO/FtarAB+t2QUHBnG v+lM8JKZ9881Q541HmmEgEX+aQBQOljhYz0+3mo2cwIPZuCmk3h3KFdIiS16v3/u cW8n9ie0+rFE0KU52TwTnOLoD+ZOXy1y3rd2/yiu/GnciSC72M0= =R9oO -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 04 14:16:37 2018 Received: (at 30701) by debbugs.gnu.org; 4 Mar 2018 19:16:37 +0000 Received: from localhost ([127.0.0.1]:44693 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esZ7d-0004PB-90 for submit@debbugs.gnu.org; Sun, 04 Mar 2018 14:16:37 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:56830 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esZ7b-0004Oj-5P for 30701@debbugs.gnu.org; Sun, 04 Mar 2018 14:16:35 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id 966D913D067; Sun, 4 Mar 2018 19:16:34 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 480FA13D069 for <30701@debbugs.gnu.org>; Sun, 4 Mar 2018 19:16:34 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id c58b994f for <30701@debbugs.gnu.org>; Sun, 4 Mar 2018 19:16:33 +0000 (UTC) From: Christopher Baines To: 30701@debbugs.gnu.org Subject: [PATCH 3/4] tests: databases: Add a system test for PostgreSQL. Date: Sun, 4 Mar 2018 19:16:32 +0000 Message-Id: <20180304191633.20262-3-mail@cbaines.net> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180304191633.20262-1-mail@cbaines.net> References: <20180304191633.20262-1-mail@cbaines.net> X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) * gnu/tests/databases.scm (%postgresql-os, %test-postgresql): New variables. (run-postgresql-test): New procedure. --- gnu/tests/databases.scm | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm index e7097690a..0597105da 100644 --- a/gnu/tests/databases.scm +++ b/gnu/tests/databases.scm @@ -30,6 +30,7 @@ #:use-module (guix store) #:export (%test-memcached %test-mongodb + %test-postgresql %test-mysql)) (define %memcached-os @@ -208,6 +209,64 @@ (value (run-mongodb-test)))) +;;; +;;; The PostgreSQL service. +;;; + +(define %postgresql-os + (simple-operating-system + (service postgresql-service-type))) + +(define* (run-postgresql-test) + "Run tests in %POSTGRESQL-OS." + (define os + (marionette-operating-system + %postgresql-os + #:imported-modules '((gnu services herd) + (guix combinators)))) + + (define vm + (virtual-machine + (operating-system os) + (memory-size 512))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (srfi srfi-11) (srfi srfi-64) + (gnu build marionette)) + + (define marionette + (make-marionette (list #$vm))) + + (mkdir #$output) + (chdir #$output) + + (test-begin "postgresql") + + (test-assert "service running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (match (start-service 'postgres) + (#f #f) + (('service response-parts ...) + (match (assq-ref response-parts 'running) + ((pid) (number? pid)))))) + marionette)) + + (test-end) + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation "postgresql-test" test)) + +(define %test-postgresql + (system-test + (name "postgresql") + (description "Start the PostgreSQL service.") + (value (run-postgresql-test)))) + + ;;; ;;; The MySQL service. ;;; -- 2.16.0 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 04 14:16:37 2018 Received: (at 30701) by debbugs.gnu.org; 4 Mar 2018 19:16:37 +0000 Received: from localhost ([127.0.0.1]:44695 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esZ7d-0004PD-Gq for submit@debbugs.gnu.org; Sun, 04 Mar 2018 14:16:37 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:56832 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esZ7b-0004Ok-55 for 30701@debbugs.gnu.org; Sun, 04 Mar 2018 14:16:35 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id A293013D069; Sun, 4 Mar 2018 19:16:34 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 6633713D064 for <30701@debbugs.gnu.org>; Sun, 4 Mar 2018 19:16:34 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 1db0088b for <30701@debbugs.gnu.org>; Sun, 4 Mar 2018 19:16:33 +0000 (UTC) From: Christopher Baines To: 30701@debbugs.gnu.org Subject: [PATCH 4/4] services: databases: Add postgresql-configuration record exports. Date: Sun, 4 Mar 2018 19:16:33 +0000 Message-Id: <20180304191633.20262-4-mail@cbaines.net> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180304191633.20262-1-mail@cbaines.net> References: <20180304191633.20262-1-mail@cbaines.net> X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) * gnu/services/databases.scm: Export the record type, and all the field accessors. --- gnu/services/databases.scm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index 4090277a7..1e410cd39 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -43,7 +43,16 @@ postgresql-config-file-external-pid-file postgresql-config-file-extra-config + + postgresql-configuration postgresql-configuration? + postgresql-configuration-postgresql + postgresql-configuration-port + postgresql-configuration-locale + postgresql-configuration-pid-file + postgresql-configuration-file + postgresql-configuration-data-directory + postgresql-service postgresql-service-type -- 2.16.0 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 04 14:16:38 2018 Received: (at 30701) by debbugs.gnu.org; 4 Mar 2018 19:16:38 +0000 Received: from localhost ([127.0.0.1]:44697 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esZ7d-0004PK-OL for submit@debbugs.gnu.org; Sun, 04 Mar 2018 14:16:38 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:56824 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esZ7b-0004Oh-5Q for 30701@debbugs.gnu.org; Sun, 04 Mar 2018 14:16:35 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id 5F0C713D06A; Sun, 4 Mar 2018 19:16:34 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 09D2213D064 for <30701@debbugs.gnu.org>; Sun, 4 Mar 2018 19:16:34 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 35e5c47c for <30701@debbugs.gnu.org>; Sun, 4 Mar 2018 19:16:33 +0000 (UTC) From: Christopher Baines To: 30701@debbugs.gnu.org Subject: [PATCH 1/4] services: Rework the PostgreSQL config file to use a record type. Date: Sun, 4 Mar 2018 19:16:30 +0000 Message-Id: <20180304191633.20262-1-mail@cbaines.net> X-Mailer: git-send-email 2.16.0 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) For the default config file representation. This makes it possible to more easily change the configuration file, and have dynamic content. In particular, I'm looking at adding a pid file location to the config file. * gnu/services/databases.scm (): New record type. (%default-postgres-config): Remove this, it's been replaced by the configuration file. (): Alter the default for the config file field. (postgresql-service): Alter the default value for the config-file parameter. --- gnu/services/databases.scm | 86 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 20 deletions(-) diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index 3ca8f471f..9ffb6a5e9 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -26,11 +26,20 @@ #:use-module (gnu system shadow) #:use-module (gnu packages admin) #:use-module (gnu packages databases) + #:use-module (guix store) #:use-module (guix modules) #:use-module (guix records) #:use-module (guix gexp) + #:use-module (srfi srfi-1) #:use-module (ice-9 match) - #:export (postgresql-configuration + #:export ( + postgresql-config-file + postgresql-config-file? + postgresql-config-file-log-destination + postgresql-config-file-hba-file + postgresql-config-file-ident-file + postgresql-config-file-extra-config + postgresql-configuration? postgresql-service postgresql-service-type @@ -68,6 +77,60 @@ ;;; ;;; Code: +(define %default-postgres-hba + (plain-file "pg_hba.conf" + " +local all all trust +host all all 127.0.0.1/32 trust +host all all ::1/128 trust")) + +(define %default-postgres-ident + (plain-file "pg_ident.conf" + "# MAPNAME SYSTEM-USERNAME PG-USERNAME")) + +(define-record-type* + postgresql-config-file make-postgresql-config-file + postgresql-config-file? + (log-destination postgresql-config-file-log-destination + (default "syslog")) + (hba-file postgresql-config-file-hba-file + (default %default-postgres-hba)) + (ident-file postgresql-config-file-ident-file + (default %default-postgres-ident)) + (extra-config postgresql-config-file-extra-config + (default '()))) + +(define-gexp-compiler (postgresql-config-file-compiler + (file ) system target) + (match file + (($ log-destination hba-file + ident-file extra-config) + (define (quote string) + (if string + (list "'" string "'") + (list))) + + (define contents + (append-map + (match-lambda + ((key) (list)) + ((key . #f) (list)) + ((key values ...) `(,key " = " ,@values "\n"))) + + `(("log_destination" ,@(quote log-destination)) + ("hba_file" ,@(quote hba-file)) + ("ident_file" ,@(quote ident-file)) + ,@extra-config))) + + (gexp->derivation + "postgresql.conf" + #~(call-with-output-file (ungexp output "out") + (lambda (port) + (display + (string-append #$@contents) + port))) + #:local-build? #t)))) + (define-record-type* postgresql-configuration make-postgresql-configuration postgresql-configuration? @@ -78,27 +141,10 @@ (locale postgresql-configuration-locale (default "en_US.utf8")) (config-file postgresql-configuration-file - (default %default-postgres-config)) + (default (postgresql-config-file))) (data-directory postgresql-configuration-data-directory (default "/var/lib/postgresql/data"))) -(define %default-postgres-hba - (plain-file "pg_hba.conf" - " -local all all trust -host all all 127.0.0.1/32 trust -host all all ::1/128 trust")) - -(define %default-postgres-ident - (plain-file "pg_ident.conf" - "# MAPNAME SYSTEM-USERNAME PG-USERNAME")) - -(define %default-postgres-config - (mixed-text-file "postgresql.conf" - "log_destination = 'syslog'\n" - "hba_file = '" %default-postgres-hba "'\n" - "ident_file = '" %default-postgres-ident "'\n")) - (define %postgresql-accounts (list (user-group (name "postgres") (system? #t)) (user-account @@ -192,7 +238,7 @@ host all all ::1/128 trust")) (define* (postgresql-service #:key (postgresql postgresql) (port 5432) (locale "en_US.utf8") - (config-file %default-postgres-config) + (config-file (postgresql-config-file)) (data-directory "/var/lib/postgresql/data")) "Return a service that runs @var{postgresql}, the PostgreSQL database server. -- 2.16.0 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 04 14:16:38 2018 Received: (at 30701) by debbugs.gnu.org; 4 Mar 2018 19:16:38 +0000 Received: from localhost ([127.0.0.1]:44699 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esZ7e-0004PS-4H for submit@debbugs.gnu.org; Sun, 04 Mar 2018 14:16:38 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:56828 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esZ7b-0004Oi-5O for 30701@debbugs.gnu.org; Sun, 04 Mar 2018 14:16:35 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id 7E13F13D06B; Sun, 4 Mar 2018 19:16:34 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 2871B13D067 for <30701@debbugs.gnu.org>; Sun, 4 Mar 2018 19:16:34 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 629eed5e for <30701@debbugs.gnu.org>; Sun, 4 Mar 2018 19:16:33 +0000 (UTC) From: Christopher Baines To: 30701@debbugs.gnu.org Subject: [PATCH 2/4] services: Use a external pid file for PostgreSQL. Date: Sun, 4 Mar 2018 19:16:31 +0000 Message-Id: <20180304191633.20262-2-mail@cbaines.net> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180304191633.20262-1-mail@cbaines.net> References: <20180304191633.20262-1-mail@cbaines.net> X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) * gnu/services/databases.scm (postgresql-pid-file-for-version): New procedure. (): Add a new external-pid-file field. (postgresql-config-file-compiler): Add support for the external-pid-file. (postgresql-activation): Create the directory for the pid file. (postgresql-shepherd-service): Use the pid-file when starting the service. --- gnu/services/databases.scm | 48 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index 9ffb6a5e9..4090277a7 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -26,10 +26,12 @@ #:use-module (gnu system shadow) #:use-module (gnu packages admin) #:use-module (gnu packages databases) + #:use-module (guix packages) #:use-module (guix store) #:use-module (guix modules) #:use-module (guix records) #:use-module (guix gexp) + #:use-module (guix utils) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export ( @@ -38,6 +40,7 @@ postgresql-config-file-log-destination postgresql-config-file-hba-file postgresql-config-file-ident-file + postgresql-config-file-external-pid-file postgresql-config-file-extra-config postgresql-configuration? @@ -88,23 +91,32 @@ host all all ::1/128 trust")) (plain-file "pg_ident.conf" "# MAPNAME SYSTEM-USERNAME PG-USERNAME")) +(define (postgresql-pid-file-for-version version) + (string-append "/var/run/postgresql/" + (version-major+minor version) + "-main.pid")) + (define-record-type* postgresql-config-file make-postgresql-config-file postgresql-config-file? - (log-destination postgresql-config-file-log-destination - (default "syslog")) - (hba-file postgresql-config-file-hba-file - (default %default-postgres-hba)) - (ident-file postgresql-config-file-ident-file - (default %default-postgres-ident)) - (extra-config postgresql-config-file-extra-config - (default '()))) + (log-destination postgresql-config-file-log-destination + (default "syslog")) + (hba-file postgresql-config-file-hba-file + (default %default-postgres-hba)) + (ident-file postgresql-config-file-ident-file + (default %default-postgres-ident)) + (external-pid-file postgresql-config-file-external-pid-file + (default (postgresql-pid-file-for-version + (package-version postgresql)))) + (extra-config postgresql-config-file-extra-config + (default '()))) (define-gexp-compiler (postgresql-config-file-compiler (file ) system target) (match file (($ log-destination hba-file - ident-file extra-config) + ident-file external-pid-file + extra-config) (define (quote string) (if string (list "'" string "'") @@ -120,6 +132,7 @@ host all all ::1/128 trust")) `(("log_destination" ,@(quote log-destination)) ("hba_file" ,@(quote hba-file)) ("ident_file" ,@(quote ident-file)) + ("external_pid_file" ,@(quote external-pid-file)) ,@extra-config))) (gexp->derivation @@ -140,6 +153,9 @@ host all all ::1/128 trust")) (default 5432)) (locale postgresql-configuration-locale (default "en_US.utf8")) + (pid-file postgresql-configuration-pid-file + (default (postgresql-pid-file-for-version + (package-version postgresql)))) (config-file postgresql-configuration-file (default (postgresql-config-file))) (data-directory postgresql-configuration-data-directory @@ -157,7 +173,8 @@ host all all ::1/128 trust")) (define postgresql-activation (match-lambda - (($ postgresql port locale config-file data-directory) + (($ postgresql port locale pid-file + config-file data-directory) #~(begin (use-modules (guix build utils) (ice-9 match)) @@ -173,6 +190,10 @@ host all all ::1/128 trust")) (mkdir-p #$data-directory) (chown #$data-directory (passwd:uid user) (passwd:gid user)) + ;; Create a directory for the pid file + (mkdir-p #$(dirname pid-file)) + (chown #$(dirname pid-file) (passwd:uid user) (passwd:gid user)) + ;; Drop privileges and init state directory in a new ;; process. Wait for it to finish before proceeding. (match (primitive-fork) @@ -195,7 +216,8 @@ host all all ::1/128 trust")) (define postgresql-shepherd-service (match-lambda - (($ postgresql port locale config-file data-directory) + (($ postgresql port locale pid-file + config-file data-directory) (let* ((pg_ctl-wrapper ;; Wrapper script that switches to the 'postgres' user before ;; launching daemon. @@ -221,7 +243,9 @@ host all all ::1/128 trust")) (provision '(postgres)) (documentation "Run the PostgreSQL daemon.") (requirement '(user-processes loopback syslogd)) - (start (action "start")) + (start #~(make-forkexec-constructor + '(#$pg_ctl-wrapper "start") + #:pid-file #$pid-file)) (stop (action "stop")))))))) (define postgresql-service-type -- 2.16.0 From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 04 19:32:15 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 00:32:15 +0000 Received: from localhost ([127.0.0.1]:44874 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ese35-0003SL-6a for submit@debbugs.gnu.org; Sun, 04 Mar 2018 19:32:15 -0500 Received: from mail.lassieur.org ([83.152.10.219]:54776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ese33-0003SC-Ad for 30701@debbugs.gnu.org; Sun, 04 Mar 2018 19:32:13 -0500 Received: from rodion (88.191.118.83 [88.191.118.83]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id c48239fc (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Mon, 5 Mar 2018 00:32:11 +0000 (UTC) References: <87po4jpsgc.fsf@cbaines.net> <20180304191633.20262-1-mail@cbaines.net> User-agent: mu4e 1.0; emacs 25.3.1 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur To: Christopher Baines Subject: Re: [bug#30701] [PATCH 1/4] services: Rework the PostgreSQL config file to use a record type. In-reply-to: <20180304191633.20262-1-mail@cbaines.net> Date: Mon, 05 Mar 2018 01:32:10 +0100 Message-ID: <87lgf7z7jp.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Hi Christopher, Christopher Baines writes: > For the default config file representation. This makes it possible to more > easily change the configuration file, and have dynamic content. In particular, > I'm looking at adding a pid file location to the config file. > > * gnu/services/databases.scm (): New record type. > (%default-postgres-config): Remove this, it's been replaced by the > configuration file. > (): Alter the default for the config file field. > (postgresql-service): Alter the default value for the config-file parameter. > --- > gnu/services/databases.scm | 86 +++++++++++++++++++++++++++++++++++----------- > 1 file changed, 66 insertions(+), 20 deletions(-) Thank you for this work! > +(define-gexp-compiler (postgresql-config-file-compiler > + (file ) system target) > + (match file > + (($ log-destination hba-file > + ident-file extra-config) > + (define (quote string) > + (if string > + (list "'" string "'") > + (list))) I don't think it's a good thing to hide one of the most important lisp functions :-). From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 04 19:32:21 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 00:32:21 +0000 Received: from localhost ([127.0.0.1]:44877 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ese3B-0003Sd-DE for submit@debbugs.gnu.org; Sun, 04 Mar 2018 19:32:21 -0500 Received: from mail.lassieur.org ([83.152.10.219]:54776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ese3A-0003SC-5Y for 30701@debbugs.gnu.org; Sun, 04 Mar 2018 19:32:20 -0500 Received: from rodion (88.191.118.83 [88.191.118.83]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id 53d7ae4e (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Mon, 5 Mar 2018 00:32:19 +0000 (UTC) References: <20180304191633.20262-1-mail@cbaines.net> <20180304191633.20262-2-mail@cbaines.net> User-agent: mu4e 1.0; emacs 25.3.1 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur To: Christopher Baines Subject: Re: [bug#30701] [PATCH 2/4] services: Use a external pid file for PostgreSQL. In-reply-to: <20180304191633.20262-2-mail@cbaines.net> Date: Mon, 05 Mar 2018 01:32:18 +0100 Message-ID: <87k1urz7jh.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Christopher Baines writes: > * gnu/services/databases.scm (postgresql-pid-file-for-version): New procedure. > (): Add a new external-pid-file field. > (postgresql-config-file-compiler): Add support for the external-pid-file. > (postgresql-activation): Create the directory for the pid file. > (postgresql-shepherd-service): Use the pid-file when starting the service. > --- > gnu/services/databases.scm | 48 ++++++++++++++++++++++++++++++++++------------ > 1 file changed, 36 insertions(+), 12 deletions(-) ... > +(define (postgresql-pid-file-for-version version) > + (string-append "/var/run/postgresql/" > + (version-major+minor version) > + "-main.pid")) > + > (define-record-type* > postgresql-config-file make-postgresql-config-file > postgresql-config-file? > - (log-destination postgresql-config-file-log-destination > - (default "syslog")) > - (hba-file postgresql-config-file-hba-file > - (default %default-postgres-hba)) > - (ident-file postgresql-config-file-ident-file > - (default %default-postgres-ident)) > - (extra-config postgresql-config-file-extra-config > - (default '()))) > + (log-destination postgresql-config-file-log-destination > + (default "syslog")) > + (hba-file postgresql-config-file-hba-file > + (default %default-postgres-hba)) > + (ident-file postgresql-config-file-ident-file > + (default %default-postgres-ident)) > + (external-pid-file postgresql-config-file-external-pid-file > + (default (postgresql-pid-file-for-version > + (package-version postgresql)))) Why does external-pid-file have a default value. It's optional, and the user already has access to $DATA/postmaster.pid anyway. > @@ -140,6 +153,9 @@ host all all ::1/128 trust")) > (default 5432)) > (locale postgresql-configuration-locale > (default "en_US.utf8")) > + (pid-file postgresql-configuration-pid-file > + (default (postgresql-pid-file-for-version > + (package-version postgresql)))) The main PID file is chosen by Postgres, and put at $DATA/postmaster.pid. I don't think it's customizable. This setting (pid-file) probably doesn't affect the daemon the way you think it does. > (config-file postgresql-configuration-file > (default (postgresql-config-file))) > (data-directory postgresql-configuration-data-directory > @@ -157,7 +173,8 @@ host all all ::1/128 trust")) > > + ;; Create a directory for the pid file > + (mkdir-p #$(dirname pid-file)) > + (chown #$(dirname pid-file) (passwd:uid user) (passwd:gid user)) I think it would make more sense to create the directory for the external-pid-file. > (define postgresql-shepherd-service > (match-lambda > - (($ postgresql port locale config-file data-directory) > + (($ postgresql port locale pid-file > + config-file data-directory) > (let* ((pg_ctl-wrapper > ;; Wrapper script that switches to the 'postgres' user before > ;; launching daemon. > @@ -221,7 +243,9 @@ host all all ::1/128 trust")) > (provision '(postgres)) > (documentation "Run the PostgreSQL daemon.") > (requirement '(user-processes loopback syslogd)) > - (start (action "start")) > + (start #~(make-forkexec-constructor > + '(#$pg_ctl-wrapper "start") > + #:pid-file #$pid-file)) > (stop (action "stop")))))))) If pid-file != external-pid-file, Sherpherd will wait for a file that doesn't exist won't it? Because Postgresql will never be aware of that pid-file. Plus, there is no reason to use make-forkexec-constructor on pg_ctl because pg_ctl returns after it has checked that the daemon is running. For the same reason, Shepherd doesn't need to know about Postgres' PID. All the hard work is done by pg_ctl. From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 04 19:32:38 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 00:32:38 +0000 Received: from localhost ([127.0.0.1]:44880 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ese3R-0003TA-Ox for submit@debbugs.gnu.org; Sun, 04 Mar 2018 19:32:37 -0500 Received: from mail.lassieur.org ([83.152.10.219]:54782) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ese3P-0003Sz-H0 for 30701@debbugs.gnu.org; Sun, 04 Mar 2018 19:32:36 -0500 Received: from rodion (88.191.118.83 [88.191.118.83]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id f1c62d63 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Mon, 5 Mar 2018 00:32:33 +0000 (UTC) References: <20180304191633.20262-1-mail@cbaines.net> <20180304191633.20262-3-mail@cbaines.net> User-agent: mu4e 1.0; emacs 25.3.1 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur To: Christopher Baines Subject: Re: [bug#30701] [PATCH 3/4] tests: databases: Add a system test for PostgreSQL. In-reply-to: <20180304191633.20262-3-mail@cbaines.net> Date: Mon, 05 Mar 2018 01:32:32 +0100 Message-ID: <87inabz7j3.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Christopher Baines writes: > * gnu/tests/databases.scm (%postgresql-os, %test-postgresql): New variables. > (run-postgresql-test): New procedure. > --- > gnu/tests/databases.scm | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 59 insertions(+) ... > + (test-assert "service running" > + (marionette-eval > + '(begin > + (use-modules (gnu services herd)) > + (match (start-service 'postgres) > + (#f #f) > + (('service response-parts ...) > + (match (assq-ref response-parts 'running) > + ((pid) (number? pid)))))) > + marionette)) I don't understand the point of the PID check here. pg_ctl will ensure that the daemon has started (by checking its PID), so I don't think there is any need to redo its work. I guess the PID you'll get here is the one of pg_ctl, which is probably not what you want. I believe that (start-service 'postgres) returning true means pg_ctl succeeded in its check that the daemon is running. So this is probably enough: (test-assert "service running" (marionette-eval '(begin (use-modules (gnu services herd)) (start-service 'postgres)) marionette)) Clément From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 02:52:28 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 07:52:28 +0000 Received: from localhost ([127.0.0.1]:45021 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eskv6-0005wQ-7d for submit@debbugs.gnu.org; Mon, 05 Mar 2018 02:52:28 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57124 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eskv4-0005wH-Q9 for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 02:52:27 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id 5286813D067; Mon, 5 Mar 2018 07:52:26 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 0E92713D064; Mon, 5 Mar 2018 07:52:26 +0000 (GMT) Received: from giedi (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 54d7234b; Mon, 5 Mar 2018 07:52:25 +0000 (UTC) References: <87po4jpsgc.fsf@cbaines.net> <20180304191633.20262-1-mail@cbaines.net> <87lgf7z7jp.fsf@lassieur.org> User-agent: mu4e 0.9.18; emacs 25.3.1 From: Christopher Baines To: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Subject: Re: [bug#30701] [PATCH 1/4] services: Rework the PostgreSQL config file to use a record type. In-reply-to: <87lgf7z7jp.fsf@lassieur.org> Date: Mon, 05 Mar 2018 07:52:25 +0000 Message-ID: <87lgf7ot6u.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cl=C3=A9ment Lassieur writes: > Hi Christopher, > > Christopher Baines writes: > >> For the default config file representation. This makes it possible to mo= re >> easily change the configuration file, and have dynamic content. In parti= cular, >> I'm looking at adding a pid file location to the config file. >> >> * gnu/services/databases.scm (): New record type. >> (%default-postgres-config): Remove this, it's been replaced by the >> configuration file. >> (): Alter the default for the config file fi= eld. >> (postgresql-service): Alter the default value for the config-file para= meter. >> --- >> gnu/services/databases.scm | 86 +++++++++++++++++++++++++++++++++++----= ------- >> 1 file changed, 66 insertions(+), 20 deletions(-) > > Thank you for this work! No problem, I've finally got around to going through some patches I've had sitting around for a while. >> +(define-gexp-compiler (postgresql-config-file-compiler >> + (file ) system target) >> + (match file >> + (($ log-destination hba-file >> + ident-file extra-config) >> + (define (quote string) >> + (if string >> + (list "'" string "'") >> + (list))) > > I don't think it's a good thing to hide one of the most important lisp > functions :-). I don't quite follow. I was trying to use '() rather than (list) if that is what you mean, but I kept getting odd errors from Guile, so I gave up, and ended up going with this. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlqc9zlfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9XdCFg/+IVM1Nsib8MPKz7604WL6PJWBQ4MKcmYjDtcPz9gCSwTQLbRqTSxH3VDK zBbs1P5fBR65Flspnh4q5A4FF30QNxsbqajUkw228TJzkchY3HB7jeTirzlmpuu+ I47emiTD9g/MKgs4QtzvTX/3X59aOcOrEbqmmGimQvANBfdgyhchlcMTQPRXyMz+ V6r3HhAxybTDoyN7A9JS9k17/A4MI3+6fh25NPJ7e6cTN1IewmzTWz46fdiOf/cl ondkwe2ZCKj2wrsHXgywiQck9skqgnThft+WxFJzbHzloDKHfhaiqqeXWO4PTJnL frImSvkvApZFYV5J67xpe4fHKVE5gRVYl6Ph1QePxMRbhPxJyQJEGQ7Uw4pV/99o fe9yZGEB8QRa7pXKh2sVMfTzlQr6bcVkpn/jT2+FxvS+9w1/496D2RzcWpifyldn WruoNpFvQzxPc+iXZ2idFGpD3mQL/YEqbymFXHnmDMXVW7ZoSAeUFf6MjCaCdvZt ow4PJvqUsgwmdgGVGVs12iA6qASQ7YAcuyEr+892D9AfstWXuNWUzji1I1hbxCcK i3GrNK3JCkT0gA1DhHJLVp+9fSbT0QcN5a8Frt3t0bz90Hb6WSNwhq3KhB2ajL48 w3SqnvU5dnoD+2rdHWqqdUNRDf60ID9attjSlJBhT24uTFCmjK8= =MzZY -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 03:21:41 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 08:21:41 +0000 Received: from localhost ([127.0.0.1]:45030 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eslNN-0006cb-0A for submit@debbugs.gnu.org; Mon, 05 Mar 2018 03:21:41 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57146 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eslNL-0006cT-F2 for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 03:21:39 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id B06BD13D067; Mon, 5 Mar 2018 08:21:38 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 59AE813D064; Mon, 5 Mar 2018 08:21:38 +0000 (GMT) Received: from giedi (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 18eea479; Mon, 5 Mar 2018 08:21:38 +0000 (UTC) References: <20180304191633.20262-1-mail@cbaines.net> <20180304191633.20262-2-mail@cbaines.net> <87k1urz7jh.fsf@lassieur.org> User-agent: mu4e 0.9.18; emacs 25.3.1 From: Christopher Baines To: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Subject: Re: [bug#30701] [PATCH 2/4] services: Use a external pid file for PostgreSQL. In-reply-to: <87k1urz7jh.fsf@lassieur.org> Date: Mon, 05 Mar 2018 08:21:35 +0000 Message-ID: <87k1uroru8.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cl=C3=A9ment Lassieur writes: > Christopher Baines writes: > >> * gnu/services/databases.scm (postgresql-pid-file-for-version): New proc= edure. >> (): Add a new external-pid-file field. >> (postgresql-config-file-compiler): Add support for the external-pid-fi= le. >> (postgresql-activation): Create the directory for the pid file. >> (postgresql-shepherd-service): Use the pid-file when starting the serv= ice. >> --- >> gnu/services/databases.scm | 48 ++++++++++++++++++++++++++++++++++-----= ------- >> 1 file changed, 36 insertions(+), 12 deletions(-) > > ... > >> +(define (postgresql-pid-file-for-version version) >> + (string-append "/var/run/postgresql/" >> + (version-major+minor version) >> + "-main.pid")) >> + >> (define-record-type* >> postgresql-config-file make-postgresql-config-file >> postgresql-config-file? >> - (log-destination postgresql-config-file-log-destination >> - (default "syslog")) >> - (hba-file postgresql-config-file-hba-file >> - (default %default-postgres-hba)) >> - (ident-file postgresql-config-file-ident-file >> - (default %default-postgres-ident)) >> - (extra-config postgresql-config-file-extra-config >> - (default '()))) >> + (log-destination postgresql-config-file-log-destination >> + (default "syslog")) >> + (hba-file postgresql-config-file-hba-file >> + (default %default-postgres-hba)) >> + (ident-file postgresql-config-file-ident-file >> + (default %default-postgres-ident)) >> + (external-pid-file postgresql-config-file-external-pid-file >> + (default (postgresql-pid-file-for-version >> + (package-version postgresql)))) > > Why does external-pid-file have a default value. It's optional, and the > user already has access to $DATA/postmaster.pid anyway. I ended up adding this as I was writing the system test. I was coping previous tests that I have written, in which I've been checking that the shepherd gets the PID back when it starts the process. Before I set out in writing this, I didn't realise that PostgreSQL stores the PID in the data directory by default, or that pg_ctl waits for actions to complete by default either. I'm not particularly attached to this patch, I guess it mostly offers consistency with other services. >> @@ -140,6 +153,9 @@ host all all ::1/128 trust")) >> (default 5432)) >> (locale postgresql-configuration-locale >> (default "en_US.utf8")) >> + (pid-file postgresql-configuration-pid-file >> + (default (postgresql-pid-file-for-version >> + (package-version postgresql)))) > > The main PID file is chosen by Postgres, and put at > $DATA/postmaster.pid. I don't think it's customizable. This setting > (pid-file) probably doesn't affect the daemon the way you think it does. This part of the configuration is just meant to be where the Guix part of the service expects to find the pid-file (if one is used, and it's not #f). >> (config-file postgresql-configuration-file >> (default (postgresql-config-file))) >> (data-directory postgresql-configuration-data-directory >> @@ -157,7 +173,8 @@ host all all ::1/128 trust")) >> >> + ;; Create a directory for the pid file >> + (mkdir-p #$(dirname pid-file)) >> + (chown #$(dirname pid-file) (passwd:uid user) (passwd:gid us= er)) > > I think it would make more sense to create the directory for the > external-pid-file. As far as I understand it, this is what this does. >> (define postgresql-shepherd-service >> (match-lambda >> - (($ postgresql port locale config-file d= ata-directory) >> + (($ postgresql port locale pid-file >> + config-file data-directory) >> (let* ((pg_ctl-wrapper >> ;; Wrapper script that switches to the 'postgres' user bef= ore >> ;; launching daemon. >> @@ -221,7 +243,9 @@ host all all ::1/128 trust")) >> (provision '(postgres)) >> (documentation "Run the PostgreSQL daemon.") >> (requirement '(user-processes loopback syslogd)) >> - (start (action "start")) >> + (start #~(make-forkexec-constructor >> + '(#$pg_ctl-wrapper "start") >> + #:pid-file #$pid-file)) >> (stop (action "stop")))))))) > > If pid-file !=3D external-pid-file, Sherpherd will wait for a file that > doesn't exist won't it? Because Postgresql will never be aware of that > pid-file. Yep. > Plus, there is no reason to use make-forkexec-constructor on pg_ctl > because pg_ctl returns after it has checked that the daemon is running. > For the same reason, Shepherd doesn't need to know about Postgres' PID. > All the hard work is done by pg_ctl. As the comment I made at the top, I did this when I was writing the system test. If you remove this patch, when you call (start-service 'postgres), it will return #f if the service starts successfully. If you tweak the service to make it fail to start (e.g. by changing the "start" action to something else), you get the same observable behaviour, start-service returns #f. The way this works for other services, normally through make-forkexec-constructor is that calling start-service will return the PID. While the system test does still add some value even without checking if the service has started, doing so would be really good. Even if it's not using the PID file approach, maybe the exit code of pg_ctl could be used? I'm not really sure why it isn't working like that already, as invoke usually returns either #t or #f... --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlqc/g9fFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9Xer6RAAlKPJ/qS8FoAqVWPl3DwNw7jcF0N9Jgj0FgWWvMNJJCqoeWamnAzSCNel zYtKQm7eAmYTnRR+fk9RPA7nCgKL55OkQus5bTu4VzKY6pEnRyDWHU/q3cUX9o4X lHbiQBkzCIfuK+cHWd78+izdNhCJXf5/ik7L9hy9QiBJGQ6NnyRZi+rgvYQdYxGw v3tXzgY1vVKMH9LJX4durscykvuQSM9PucZk77ckYipZ/kPaBLyplfTkuRfvK6ld 3kbMbYoQCUyz5JCzLqmB/shNVT8Gt5EEYjSWaLkNt4k/VpPrO6sXiHgtXD8b+M70 F/8P6/M72nOpbRKjUfVFZ9RJ5ghXzkxhOlBVAveLdqQy+mTVR29B+uzb9NKxnGoF AUPlxi59P+KiHA9mBcNW4rpgwX7Y6lVuzw2wc8qTeUcxV+Fsf8nYtKJeo9tqw7o/ iPYZsVStBwDBqnKh7YnXTWmzeGx+KGp2vJ1PrmYzPPqg8HKmSrfkgK+luCm9twRN i3VIU8UamAPHFWlOVFnkmecOYamGR7D4ms74EahWMUT2cg+uK0BgjlHm5H4Pvu2C wHLyxXdVexj2Q4FrSX5I3gaa81GYnsdHyaPWUb4YrxpoGGbQOYjxUNhGaJoNOpbn j9JQg9vY2pTaMEIRm8aJWsDfvKDGITe/S79fCJCqPn30QzdS328= =3sSe -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 03:28:02 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 08:28:02 +0000 Received: from localhost ([127.0.0.1]:45034 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eslTV-0006lh-SD for submit@debbugs.gnu.org; Mon, 05 Mar 2018 03:28:02 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57158 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eslTU-0006lZ-3d for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 03:28:00 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id 64B2013D069; Mon, 5 Mar 2018 08:27:59 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 1238313D064; Mon, 5 Mar 2018 08:27:59 +0000 (GMT) Received: from giedi (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id b4178fb9; Mon, 5 Mar 2018 08:27:58 +0000 (UTC) References: <20180304191633.20262-1-mail@cbaines.net> <20180304191633.20262-2-mail@cbaines.net> <87k1urz7jh.fsf@lassieur.org> <87k1uroru8.fsf@cbaines.net> User-agent: mu4e 0.9.18; emacs 25.3.1 From: Christopher Baines To: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Subject: Re: [bug#30701] [PATCH 2/4] services: Use a external pid file for PostgreSQL. In-reply-to: <87k1uroru8.fsf@cbaines.net> Date: Mon, 05 Mar 2018 08:27:55 +0000 Message-ID: <87inaborjo.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Christopher Baines writes: > Cl=C3=A9ment Lassieur writes: > >> Plus, there is no reason to use make-forkexec-constructor on pg_ctl >> because pg_ctl returns after it has checked that the daemon is running. >> For the same reason, Shepherd doesn't need to know about Postgres' PID. >> All the hard work is done by pg_ctl. > > As the comment I made at the top, I did this when I was writing the > system test. If you remove this patch, when you call (start-service > 'postgres), it will return #f if the service starts successfully. If you > tweak the service to make it fail to start (e.g. by changing the "start" > action to something else), you get the same observable behaviour, > start-service returns #f. > > The way this works for other services, normally through > make-forkexec-constructor is that calling start-service will return the > PID. > > While the system test does still add some value even without checking if > the service has started, doing so would be really good. Even if it's not > using the PID file approach, maybe the exit code of pg_ctl could be > used? I'm not really sure why it isn't working like that already, as > invoke usually returns either #t or #f... Ah, I've just realised why this is the case, I was misreading the system test results, it does actually return #t/#f, but as the system test was expecting a number, it just returns #f to indicate failure. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlqc/4tfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9Xf4hQ//aiNn3T2pacYGLKmT0rHiiIC3WJvaChs3H2p9D1eSg4FowDV26IsJfmT/ stjmgGcqIQ3cv6tyycfXcYQSxOhJsw5NXN+rHDXOXfpHwb/RqxBjgXk79OWwZ3Tr BbJ+0vzzx8cY+bePbtNenhHNiLDs9b+oPoqEiCvOq/We8zz3/9EmJqx3CvztGhc6 7ps9iFZ9lsWLrf5tk/2q2ff+ogXKVfTVF72wZdnFLGPshA60WduT4kDZEZp7qVPN Mzo4ersRaF8rlOH3nUMdqzK1kFVMt65T5NQx23pbv3mSFxz5zmk5NP/OjkNsmnM8 DRKSeT3BkpTYFHt9fZCQjnZ4n/R2Pdb25t3FVlF2Hls/9PdHCK6ar62oRANAeHwd tuG5c2ZQO7QGV7o8gaF5nuW2ZtlP+ijljCmZ6wEQxymAP7ojeRYlsFojCqv6uYMw P7nc2OedYRaUHfP6/BBkRn0FktOrh8DuVjHvAzbzGXx6Y+V6nN3m2qzhk7+gDFqg SuMfMSoXVlOMpSTFLYt30vTN+2VmnQq/ByKThqPYYMMWcAB1p0Y/QIcDgwHOmtab OKPrdlHhI3d7iE31JXyJk5hWfwxvXN5jD4Vri8W75EkTXaujNoK7JMoW5hqKYj5W Xv/kafDaMY6En/e7jqFULYtWxKa/S/jcRCUOvoEiF49NxogWqH0= =50nr -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 03:34:39 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 08:34:39 +0000 Received: from localhost ([127.0.0.1]:45042 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eslZu-0006ww-UZ for submit@debbugs.gnu.org; Mon, 05 Mar 2018 03:34:39 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57172 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eslZt-0006wp-T2 for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 03:34:38 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id 2E79113D067; Mon, 5 Mar 2018 08:34:37 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id D9E1613D064; Mon, 5 Mar 2018 08:34:36 +0000 (GMT) Received: from giedi (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 7769fabf; Mon, 5 Mar 2018 08:34:36 +0000 (UTC) References: <20180304191633.20262-1-mail@cbaines.net> <20180304191633.20262-3-mail@cbaines.net> <87inabz7j3.fsf@lassieur.org> User-agent: mu4e 0.9.18; emacs 25.3.1 From: Christopher Baines To: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Subject: Re: [bug#30701] [PATCH 3/4] tests: databases: Add a system test for PostgreSQL. In-reply-to: <87inabz7j3.fsf@lassieur.org> Date: Mon, 05 Mar 2018 08:34:33 +0000 Message-ID: <87h8puq5t2.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cl=C3=A9ment Lassieur writes: > Christopher Baines writes: > >> * gnu/tests/databases.scm (%postgresql-os, %test-postgresql): New variab= les. >> (run-postgresql-test): New procedure. >> --- >> gnu/tests/databases.scm | 59 ++++++++++++++++++++++++++++++++++++++++++= +++++++ >> 1 file changed, 59 insertions(+) > ... > >> + (test-assert "service running" >> + (marionette-eval >> + '(begin >> + (use-modules (gnu services herd)) >> + (match (start-service 'postgres) >> + (#f #f) >> + (('service response-parts ...) >> + (match (assq-ref response-parts 'running) >> + ((pid) (number? pid)))))) >> + marionette)) > > I don't understand the point of the PID check here. pg_ctl will ensure > that the daemon has started (by checking its PID), so I don't think > there is any need to redo its work. I guess the PID you'll get here is > the one of pg_ctl, which is probably not what you want. Because of make-forkexec-constructor, it is the main PID as set in the external pid file created by PostgreSQL. > I believe that (start-service 'postgres) returning true means pg_ctl > succeeded in its check that the daemon is running. So this is probably > enough: > > (test-assert "service running" > (marionette-eval > '(begin > (use-modules (gnu services herd)) > (start-service 'postgres)) > marionette)) Sure, I'm happy with this. I'll send some new patches soonish. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlqdARlfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9XdJsBAAoefkU/Hl1UwsPHIDFqQWfs/pHbhbu4X1BMrYcYx78GWwR3bCMaUd92dp ctQ3NT/RruWFmj3mfGxhAwTaIuBoe9Z5vnlafMnB3AJ0M+lgCmRtt/UYPQv9MGCR 6qwfkquMqEYxf9R4mhcTkOpt4rFGkQAzSeOiui9KEInbVe3tS9LcFUqL75FsI1rT H7KsVGF8mi8SD1oyZLBBsY+Z6fNOYwAFk+8NrRVZWxofyZKe/Y8qQueIq6oLJb5e nJGmCrHTQeQMPYLb06BI7QcBZr7skkwoBMqvT0VEsdZc37PP4xg0B/i4GzhGNcrc NsjOHpIUo83u63l+s5lIZbCWKZDo0RuPDCeMa1V4wvwA+Ti24nAAWBRtLvS5WVUm J0rYHRb9YmdWBZsBAdU3Hd1AQ13Qe4mPI81K1n5K+KSXvQVcB63/ExtHutoZgIaw H8ayyfrJp5ngwbIbAmleC0woXq9XybGpZ7XOz5+0PmthhWgVkqYksQCZNgh4QAJQ Uqbh056mY0TN7/pfGBOWPyDuju8HA5OAJ2KzCu+QcC27XhwgkdXObQrr6S9DhHCE ShtJqxgdP0o+TAi91IYSn2peqXfTzYo1iIOMejd9ujvU+iPGekJocQFBomzgtWjr rtU5Qu7CjWKTdIecybNuSDFTtO4FEVtp9HKzZ62Eep4nOwvUicY= =x3LN -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 03:39:20 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 08:39:20 +0000 Received: from localhost ([127.0.0.1]:45055 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esleR-00074Q-S2 for submit@debbugs.gnu.org; Mon, 05 Mar 2018 03:39:20 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57190 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esleQ-000747-5F for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 03:39:18 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id B0E3313D064; Mon, 5 Mar 2018 08:39:17 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 7236213D067 for <30701@debbugs.gnu.org>; Mon, 5 Mar 2018 08:39:17 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 737f8d17 for <30701@debbugs.gnu.org>; Mon, 5 Mar 2018 08:39:17 +0000 (UTC) From: Christopher Baines To: 30701@debbugs.gnu.org Subject: [PATCH 2/3] tests: databases: Add a system test for PostgreSQL. Date: Mon, 5 Mar 2018 08:39:16 +0000 Message-Id: <20180305083917.24122-2-mail@cbaines.net> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180305083917.24122-1-mail@cbaines.net> References: <20180305083917.24122-1-mail@cbaines.net> X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) * gnu/tests/databases.scm (%postgresql-os, %test-postgresql): New variables. (run-postgresql-test): New procedure. --- gnu/tests/databases.scm | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm index e7097690a..583f484d7 100644 --- a/gnu/tests/databases.scm +++ b/gnu/tests/databases.scm @@ -30,6 +30,7 @@ #:use-module (guix store) #:export (%test-memcached %test-mongodb + %test-postgresql %test-mysql)) (define %memcached-os @@ -208,6 +209,60 @@ (value (run-mongodb-test)))) +;;; +;;; The PostgreSQL service. +;;; + +(define %postgresql-os + (simple-operating-system + (service postgresql-service-type))) + +(define* (run-postgresql-test) + "Run tests in %POSTGRESQL-OS." + (define os + (marionette-operating-system + %postgresql-os + #:imported-modules '((gnu services herd) + (guix combinators)))) + + (define vm + (virtual-machine + (operating-system os) + (memory-size 512))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (srfi srfi-11) (srfi srfi-64) + (gnu build marionette)) + + (define marionette + (make-marionette (list #$vm))) + + (mkdir #$output) + (chdir #$output) + + (test-begin "postgresql") + + (test-assert "service running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'postgres)) + marionette)) + + (test-end) + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation "postgresql-test" test)) + +(define %test-postgresql + (system-test + (name "postgresql") + (description "Start the PostgreSQL service.") + (value (run-postgresql-test)))) + + ;;; ;;; The MySQL service. ;;; -- 2.16.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 03:39:20 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 08:39:20 +0000 Received: from localhost ([127.0.0.1]:45057 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esleS-00074T-2v for submit@debbugs.gnu.org; Mon, 05 Mar 2018 03:39:20 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57192 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esleQ-000748-7m for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 03:39:18 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id C832213D067; Mon, 5 Mar 2018 08:39:17 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 88D7F13D069 for <30701@debbugs.gnu.org>; Mon, 5 Mar 2018 08:39:17 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 992e4028 for <30701@debbugs.gnu.org>; Mon, 5 Mar 2018 08:39:17 +0000 (UTC) From: Christopher Baines To: 30701@debbugs.gnu.org Subject: [PATCH 3/3] services: databases: Add postgresql-configuration record exports. Date: Mon, 5 Mar 2018 08:39:17 +0000 Message-Id: <20180305083917.24122-3-mail@cbaines.net> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180305083917.24122-1-mail@cbaines.net> References: <20180305083917.24122-1-mail@cbaines.net> X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) * gnu/services/databases.scm: Export the record type, and all the field accessors. --- gnu/services/databases.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index 9ffb6a5e9..b05c0442f 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -40,7 +40,15 @@ postgresql-config-file-ident-file postgresql-config-file-extra-config + + postgresql-configuration postgresql-configuration? + postgresql-configuration-postgresql + postgresql-configuration-port + postgresql-configuration-locale + postgresql-configuration-file + postgresql-configuration-data-directory + postgresql-service postgresql-service-type -- 2.16.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 03:39:20 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 08:39:20 +0000 Received: from localhost ([127.0.0.1]:45059 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esleS-00074a-Au for submit@debbugs.gnu.org; Mon, 05 Mar 2018 03:39:20 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57188 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esleQ-000746-4Z for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 03:39:18 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id A2E5E13D06A; Mon, 5 Mar 2018 08:39:17 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 5A77C13D064 for <30701@debbugs.gnu.org>; Mon, 5 Mar 2018 08:39:17 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id c8131a1e for <30701@debbugs.gnu.org>; Mon, 5 Mar 2018 08:39:17 +0000 (UTC) From: Christopher Baines To: 30701@debbugs.gnu.org Subject: [PATCH 1/3] services: Rework the PostgreSQL config file to use a record type. Date: Mon, 5 Mar 2018 08:39:15 +0000 Message-Id: <20180305083917.24122-1-mail@cbaines.net> X-Mailer: git-send-email 2.16.0 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) For the default config file representation. This makes it possible to more easily change the configuration file, and have dynamic content. In particular, I'm looking at adding a pid file location to the config file. * gnu/services/databases.scm (): New record type. (%default-postgres-config): Remove this, it's been replaced by the configuration file. (): Alter the default for the config file field. (postgresql-service): Alter the default value for the config-file parameter. --- gnu/services/databases.scm | 86 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 20 deletions(-) diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index 3ca8f471f..9ffb6a5e9 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -26,11 +26,20 @@ #:use-module (gnu system shadow) #:use-module (gnu packages admin) #:use-module (gnu packages databases) + #:use-module (guix store) #:use-module (guix modules) #:use-module (guix records) #:use-module (guix gexp) + #:use-module (srfi srfi-1) #:use-module (ice-9 match) - #:export (postgresql-configuration + #:export ( + postgresql-config-file + postgresql-config-file? + postgresql-config-file-log-destination + postgresql-config-file-hba-file + postgresql-config-file-ident-file + postgresql-config-file-extra-config + postgresql-configuration? postgresql-service postgresql-service-type @@ -68,6 +77,60 @@ ;;; ;;; Code: +(define %default-postgres-hba + (plain-file "pg_hba.conf" + " +local all all trust +host all all 127.0.0.1/32 trust +host all all ::1/128 trust")) + +(define %default-postgres-ident + (plain-file "pg_ident.conf" + "# MAPNAME SYSTEM-USERNAME PG-USERNAME")) + +(define-record-type* + postgresql-config-file make-postgresql-config-file + postgresql-config-file? + (log-destination postgresql-config-file-log-destination + (default "syslog")) + (hba-file postgresql-config-file-hba-file + (default %default-postgres-hba)) + (ident-file postgresql-config-file-ident-file + (default %default-postgres-ident)) + (extra-config postgresql-config-file-extra-config + (default '()))) + +(define-gexp-compiler (postgresql-config-file-compiler + (file ) system target) + (match file + (($ log-destination hba-file + ident-file extra-config) + (define (quote string) + (if string + (list "'" string "'") + (list))) + + (define contents + (append-map + (match-lambda + ((key) (list)) + ((key . #f) (list)) + ((key values ...) `(,key " = " ,@values "\n"))) + + `(("log_destination" ,@(quote log-destination)) + ("hba_file" ,@(quote hba-file)) + ("ident_file" ,@(quote ident-file)) + ,@extra-config))) + + (gexp->derivation + "postgresql.conf" + #~(call-with-output-file (ungexp output "out") + (lambda (port) + (display + (string-append #$@contents) + port))) + #:local-build? #t)))) + (define-record-type* postgresql-configuration make-postgresql-configuration postgresql-configuration? @@ -78,27 +141,10 @@ (locale postgresql-configuration-locale (default "en_US.utf8")) (config-file postgresql-configuration-file - (default %default-postgres-config)) + (default (postgresql-config-file))) (data-directory postgresql-configuration-data-directory (default "/var/lib/postgresql/data"))) -(define %default-postgres-hba - (plain-file "pg_hba.conf" - " -local all all trust -host all all 127.0.0.1/32 trust -host all all ::1/128 trust")) - -(define %default-postgres-ident - (plain-file "pg_ident.conf" - "# MAPNAME SYSTEM-USERNAME PG-USERNAME")) - -(define %default-postgres-config - (mixed-text-file "postgresql.conf" - "log_destination = 'syslog'\n" - "hba_file = '" %default-postgres-hba "'\n" - "ident_file = '" %default-postgres-ident "'\n")) - (define %postgresql-accounts (list (user-group (name "postgres") (system? #t)) (user-account @@ -192,7 +238,7 @@ host all all ::1/128 trust")) (define* (postgresql-service #:key (postgresql postgresql) (port 5432) (locale "en_US.utf8") - (config-file %default-postgres-config) + (config-file (postgresql-config-file)) (data-directory "/var/lib/postgresql/data")) "Return a service that runs @var{postgresql}, the PostgreSQL database server. -- 2.16.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 03:52:15 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 08:52:16 +0000 Received: from localhost ([127.0.0.1]:45066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eslqx-0007Nr-Lx for submit@debbugs.gnu.org; Mon, 05 Mar 2018 03:52:15 -0500 Received: from mail.lassieur.org ([83.152.10.219]:54786) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eslqv-0007Ni-HY for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 03:52:14 -0500 Received: from rodion (88.191.118.83 [88.191.118.83]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id cad88817 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Mon, 5 Mar 2018 08:52:11 +0000 (UTC) References: <87po4jpsgc.fsf@cbaines.net> <20180304191633.20262-1-mail@cbaines.net> <87lgf7z7jp.fsf@lassieur.org> <87lgf7ot6u.fsf@cbaines.net> User-agent: mu4e 1.0; emacs 25.3.1 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur To: Christopher Baines Subject: Re: [bug#30701] [PATCH 1/4] services: Rework the PostgreSQL config file to use a record type. In-reply-to: <87lgf7ot6u.fsf@cbaines.net> Date: Mon, 05 Mar 2018 09:52:11 +0100 Message-ID: <87h8puzyys.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Christopher Baines writes: > Clément Lassieur writes: > >> Hi Christopher, >> >> Christopher Baines writes: >> >>> For the default config file representation. This makes it possible to more >>> easily change the configuration file, and have dynamic content. In particular, >>> I'm looking at adding a pid file location to the config file. >>> >>> * gnu/services/databases.scm (): New record type. >>> (%default-postgres-config): Remove this, it's been replaced by the >>> configuration file. >>> (): Alter the default for the config file field. >>> (postgresql-service): Alter the default value for the config-file parameter. >>> --- >>> gnu/services/databases.scm | 86 +++++++++++++++++++++++++++++++++++----------- >>> 1 file changed, 66 insertions(+), 20 deletions(-) >> >> Thank you for this work! > > No problem, I've finally got around to going through some patches I've > had sitting around for a while. > >>> +(define-gexp-compiler (postgresql-config-file-compiler >>> + (file ) system target) >>> + (match file >>> + (($ log-destination hba-file >>> + ident-file extra-config) >>> + (define (quote string) >>> + (if string >>> + (list "'" string "'") >>> + (list))) >> >> I don't think it's a good thing to hide one of the most important lisp >> functions :-). > > I don't quite follow. I was trying to use '() rather than (list) if that > is what you mean, but I kept getting odd errors from Guile, so I gave > up, and ended up going with this. Sorry for not being clear. I meant that if you define 'quote', you won't be able to use the Guile 'quote' anymore. See https://www.gnu.org/software/guile/manual/html_node/Expression-Syntax.html. You could just rename it to 'quote-val' or something else. From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 04:35:52 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 09:35:52 +0000 Received: from localhost ([127.0.0.1]:45127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esmX9-0008Vl-SO for submit@debbugs.gnu.org; Mon, 05 Mar 2018 04:35:52 -0500 Received: from mail.lassieur.org ([83.152.10.219]:54790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esmX9-0008Vd-3a for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 04:35:51 -0500 Received: from newt (46.218.109.88 [46.218.109.88]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id e537a6f2 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Mon, 5 Mar 2018 09:35:49 +0000 (UTC) References: <87po4jpsgc.fsf@cbaines.net> <20180304191633.20262-1-mail@cbaines.net> <87lgf7z7jp.fsf@lassieur.org> <87lgf7ot6u.fsf@cbaines.net> User-agent: mu4e 1.0; emacs 25.3.1 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur To: Christopher Baines Subject: Re: [bug#30701] [PATCH 1/4] services: Rework the PostgreSQL config file to use a record type. In-reply-to: <87lgf7ot6u.fsf@cbaines.net> Date: Mon, 05 Mar 2018 10:35:49 +0100 Message-ID: <87efkyzwy2.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Christopher Baines writes: > Clément Lassieur writes: > >> Hi Christopher, >> >> Christopher Baines writes: >> >>> For the default config file representation. This makes it possible to more >>> easily change the configuration file, and have dynamic content. In particular, >>> I'm looking at adding a pid file location to the config file. >>> >>> * gnu/services/databases.scm (): New record type. >>> (%default-postgres-config): Remove this, it's been replaced by the >>> configuration file. >>> (): Alter the default for the config file field. >>> (postgresql-service): Alter the default value for the config-file parameter. >>> --- >>> gnu/services/databases.scm | 86 +++++++++++++++++++++++++++++++++++----------- >>> 1 file changed, 66 insertions(+), 20 deletions(-) >> >> Thank you for this work! > > No problem, I've finally got around to going through some patches I've > had sitting around for a while. > >>> +(define-gexp-compiler (postgresql-config-file-compiler >>> + (file ) system target) >>> + (match file >>> + (($ log-destination hba-file >>> + ident-file extra-config) >>> + (define (quote string) >>> + (if string >>> + (list "'" string "'") >>> + (list))) >> >> I don't think it's a good thing to hide one of the most important lisp >> functions :-). > > I don't quite follow. I was trying to use '() rather than (list) if that > is what you mean, but I kept getting odd errors from Guile, so I gave > up, and ended up going with this. You couldn't use '() because '() is the same thing as (quote ()) and you redefined 'quote'. From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 06:54:58 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 11:54:58 +0000 Received: from localhost ([127.0.0.1]:45192 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esohm-0003Mr-Bs for submit@debbugs.gnu.org; Mon, 05 Mar 2018 06:54:58 -0500 Received: from mail.lassieur.org ([83.152.10.219]:54856) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esohk-0003Mi-Fl for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 06:54:57 -0500 Received: from newt (46.218.109.88 [46.218.109.88]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id a60021e7 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Mon, 5 Mar 2018 11:54:54 +0000 (UTC) References: <20180305083917.24122-1-mail@cbaines.net> <20180305083917.24122-2-mail@cbaines.net> User-agent: mu4e 1.0; emacs 25.3.1 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur To: Christopher Baines Subject: Re: [bug#30701] [PATCH 2/3] tests: databases: Add a system test for PostgreSQL. In-reply-to: <20180305083917.24122-2-mail@cbaines.net> Date: Mon, 05 Mar 2018 12:54:53 +0100 Message-ID: <87d10izqia.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Christopher Baines writes: > * gnu/tests/databases.scm (%postgresql-os, %test-postgresql): New variables. > (run-postgresql-test): New procedure. > --- > gnu/tests/databases.scm | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 55 insertions(+) > > diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm > index e7097690a..583f484d7 100644 > --- a/gnu/tests/databases.scm > +++ b/gnu/tests/databases.scm > @@ -30,6 +30,7 @@ > #:use-module (guix store) > #:export (%test-memcached > %test-mongodb > + %test-postgresql > %test-mysql)) > > (define %memcached-os > @@ -208,6 +209,60 @@ > (value (run-mongodb-test)))) > > > +;;; > +;;; The PostgreSQL service. > +;;; > + > +(define %postgresql-os > + (simple-operating-system > + (service postgresql-service-type))) > + > +(define* (run-postgresql-test) define, instead of define* > + "Run tests in %POSTGRESQL-OS." > + (define os > + (marionette-operating-system > + %postgresql-os > + #:imported-modules '((gnu services herd) > + (guix combinators)))) > + > + (define vm > + (virtual-machine > + (operating-system os) > + (memory-size 512))) > + > + (define test > + (with-imported-modules '((gnu build marionette)) > + #~(begin > + (use-modules (srfi srfi-11) (srfi srfi-64) I think srfi-11 is useless. > + (gnu build marionette)) > + > + (define marionette > + (make-marionette (list #$vm))) > + > + (mkdir #$output) > + (chdir #$output) > + > + (test-begin "postgresql") > + > + (test-assert "service running" > + (marionette-eval > + '(begin > + (use-modules (gnu services herd)) > + (start-service 'postgres)) > + marionette)) > + > + (test-end) > + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) > + > + (gexp->derivation "postgresql-test" test)) > + > +(define %test-postgresql > + (system-test > + (name "postgresql") > + (description "Start the PostgreSQL service.") > + (value (run-postgresql-test)))) > + > + > ;;; > ;;; The MySQL service. > ;;; From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 07:15:39 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 12:15:39 +0000 Received: from localhost ([127.0.0.1]:45197 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esp1n-0003rP-5v for submit@debbugs.gnu.org; Mon, 05 Mar 2018 07:15:39 -0500 Received: from mail.lassieur.org ([83.152.10.219]:54860) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esp1l-0003rH-V7 for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 07:15:38 -0500 Received: from newt (46.218.109.88 [46.218.109.88]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id e11c3683 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Mon, 5 Mar 2018 12:15:36 +0000 (UTC) References: <20180304191633.20262-1-mail@cbaines.net> <20180304191633.20262-2-mail@cbaines.net> <87k1urz7jh.fsf@lassieur.org> <87k1uroru8.fsf@cbaines.net> User-agent: mu4e 1.0; emacs 25.3.1 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur To: Christopher Baines Subject: Re: [bug#30701] [PATCH 2/4] services: Use a external pid file for PostgreSQL. In-reply-to: <87k1uroru8.fsf@cbaines.net> Date: Mon, 05 Mar 2018 13:15:36 +0100 Message-ID: <87bmg2zpjr.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Christopher Baines writes: > Clément Lassieur writes: > >> Christopher Baines writes: >> >>> * gnu/services/databases.scm (postgresql-pid-file-for-version): New procedure. >>> (): Add a new external-pid-file field. >>> (postgresql-config-file-compiler): Add support for the external-pid-file. >>> (postgresql-activation): Create the directory for the pid file. >>> (postgresql-shepherd-service): Use the pid-file when starting the service. >>> --- >>> gnu/services/databases.scm | 48 ++++++++++++++++++++++++++++++++++------------ >>> 1 file changed, 36 insertions(+), 12 deletions(-) >> >> ... >> >>> +(define (postgresql-pid-file-for-version version) >>> + (string-append "/var/run/postgresql/" >>> + (version-major+minor version) >>> + "-main.pid")) >>> + >>> (define-record-type* >>> postgresql-config-file make-postgresql-config-file >>> postgresql-config-file? >>> - (log-destination postgresql-config-file-log-destination >>> - (default "syslog")) >>> - (hba-file postgresql-config-file-hba-file >>> - (default %default-postgres-hba)) >>> - (ident-file postgresql-config-file-ident-file >>> - (default %default-postgres-ident)) >>> - (extra-config postgresql-config-file-extra-config >>> - (default '()))) >>> + (log-destination postgresql-config-file-log-destination >>> + (default "syslog")) >>> + (hba-file postgresql-config-file-hba-file >>> + (default %default-postgres-hba)) >>> + (ident-file postgresql-config-file-ident-file >>> + (default %default-postgres-ident)) >>> + (external-pid-file postgresql-config-file-external-pid-file >>> + (default (postgresql-pid-file-for-version >>> + (package-version postgresql)))) >> >> Why does external-pid-file have a default value. It's optional, and the >> user already has access to $DATA/postmaster.pid anyway. > > I ended up adding this as I was writing the system test. I was coping > previous tests that I have written, in which I've been checking that the > shepherd gets the PID back when it starts the process. > > Before I set out in writing this, I didn't realise that PostgreSQL > stores the PID in the data directory by default, or that pg_ctl waits > for actions to complete by default either. > > I'm not particularly attached to this patch, I guess it mostly offers > consistency with other services. > >>> @@ -140,6 +153,9 @@ host all all ::1/128 trust")) >>> (default 5432)) >>> (locale postgresql-configuration-locale >>> (default "en_US.utf8")) >>> + (pid-file postgresql-configuration-pid-file >>> + (default (postgresql-pid-file-for-version >>> + (package-version postgresql)))) >> >> The main PID file is chosen by Postgres, and put at >> $DATA/postmaster.pid. I don't think it's customizable. This setting >> (pid-file) probably doesn't affect the daemon the way you think it does. > > This part of the configuration is just meant to be where the Guix part > of the service expects to find the pid-file (if one is used, and it's > not #f). > >>> (config-file postgresql-configuration-file >>> (default (postgresql-config-file))) >>> (data-directory postgresql-configuration-data-directory >>> @@ -157,7 +173,8 @@ host all all ::1/128 trust")) >>> >>> + ;; Create a directory for the pid file >>> + (mkdir-p #$(dirname pid-file)) >>> + (chown #$(dirname pid-file) (passwd:uid user) (passwd:gid user)) >> >> I think it would make more sense to create the directory for the >> external-pid-file. > > As far as I understand it, this is what this does. > >>> (define postgresql-shepherd-service >>> (match-lambda >>> - (($ postgresql port locale config-file data-directory) >>> + (($ postgresql port locale pid-file >>> + config-file data-directory) >>> (let* ((pg_ctl-wrapper >>> ;; Wrapper script that switches to the 'postgres' user before >>> ;; launching daemon. >>> @@ -221,7 +243,9 @@ host all all ::1/128 trust")) >>> (provision '(postgres)) >>> (documentation "Run the PostgreSQL daemon.") >>> (requirement '(user-processes loopback syslogd)) >>> - (start (action "start")) >>> + (start #~(make-forkexec-constructor >>> + '(#$pg_ctl-wrapper "start") >>> + #:pid-file #$pid-file)) >>> (stop (action "stop")))))))) >> >> If pid-file != external-pid-file, Sherpherd will wait for a file that >> doesn't exist won't it? Because Postgresql will never be aware of that >> pid-file. > > Yep. > >> Plus, there is no reason to use make-forkexec-constructor on pg_ctl >> because pg_ctl returns after it has checked that the daemon is running. >> For the same reason, Shepherd doesn't need to know about Postgres' PID. >> All the hard work is done by pg_ctl. > > As the comment I made at the top, I did this when I was writing the > system test. If you remove this patch, when you call (start-service > 'postgres), it will return #f if the service starts successfully. If you > tweak the service to make it fail to start (e.g. by changing the "start" > action to something else), you get the same observable behaviour, > start-service returns #f. > > The way this works for other services, normally through > make-forkexec-constructor is that calling start-service will return the > PID. > > While the system test does still add some value even without checking if > the service has started, doing so would be really good. Even if it's not > using the PID file approach, maybe the exit code of pg_ctl could be > used? I'm not really sure why it isn't working like that already, as > invoke usually returns either #t or #f... The PID approch only makes sense when the executable run by Shepherd doesn't return; i.e. it blocks. Then Shepherd needs to fork a child process (with make-forkexec-constructor), so that it doesn't block. And the only way to know if the daemon has started is to find a "proof", which is the PID file. That's the point of the #:pid-file parameter of make-forkexec-constructor. But the PostgreSQL package is more elaborate: it provides an 'pg_ctl' executable that does all the hard work: - starting the daemon, - checking its PID to make sure the daemon is running, - exiting with 0 if the daemon is running. So Shepherd doesn't need to fork, it just checks the return value of pg_ctl. Conclusion: (start-service 'postgres) returning #t means that pg_ctl exit code is 0, which means that the daemon is running. I hope it makes more sense :-) From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 07:16:50 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 12:16:50 +0000 Received: from localhost ([127.0.0.1]:45201 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esp2v-0003tS-OA for submit@debbugs.gnu.org; Mon, 05 Mar 2018 07:16:49 -0500 Received: from mail.lassieur.org ([83.152.10.219]:54866) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esp2t-0003tJ-OC for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 07:16:48 -0500 Received: from newt (46.218.109.88 [46.218.109.88]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id 81432700 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Mon, 5 Mar 2018 12:16:46 +0000 (UTC) References: <20180304191633.20262-1-mail@cbaines.net> <20180304191633.20262-4-mail@cbaines.net> User-agent: mu4e 1.0; emacs 25.3.1 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur To: Christopher Baines Subject: Re: [bug#30701] [PATCH 4/4] services: databases: Add postgresql-configuration record exports. In-reply-to: <20180304191633.20262-4-mail@cbaines.net> Date: Mon, 05 Mar 2018 13:16:46 +0100 Message-ID: <87a7vmzpht.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Christopher Baines writes: > * gnu/services/databases.scm: Export the record type, and all the field > accessors. ^ Small nit-pick: there is no indentation here :-). You can check "git log" to see how other people do. > --- > gnu/services/databases.scm | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm > index 4090277a7..1e410cd39 100644 > --- a/gnu/services/databases.scm > +++ b/gnu/services/databases.scm > @@ -43,7 +43,16 @@ > postgresql-config-file-external-pid-file > postgresql-config-file-extra-config > > + > + postgresql-configuration > postgresql-configuration? > + postgresql-configuration-postgresql > + postgresql-configuration-port > + postgresql-configuration-locale > + postgresql-configuration-pid-file > + postgresql-configuration-file > + postgresql-configuration-data-directory > + > postgresql-service > postgresql-service-type From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 14:25:42 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 19:25:42 +0000 Received: from localhost ([127.0.0.1]:46224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esvjx-0001CF-Qf for submit@debbugs.gnu.org; Mon, 05 Mar 2018 14:25:42 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57786 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esvjw-0001C8-5Z for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 14:25:40 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id 8BA1813D069; Mon, 5 Mar 2018 19:25:39 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id CA33D13D064; Mon, 5 Mar 2018 19:25:38 +0000 (GMT) Received: from giedi (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id ee14ef0e; Mon, 5 Mar 2018 19:25:38 +0000 (UTC) References: <20180305083917.24122-1-mail@cbaines.net> <20180305083917.24122-2-mail@cbaines.net> <87d10izqia.fsf@lassieur.org> User-agent: mu4e 0.9.18; emacs 25.3.1 From: Christopher Baines To: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Subject: Re: [bug#30701] [PATCH 2/3] tests: databases: Add a system test for PostgreSQL. In-reply-to: <87d10izqia.fsf@lassieur.org> Date: Mon, 05 Mar 2018 19:25:38 +0000 Message-ID: <87efkypbnx.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cl=C3=A9ment Lassieur writes: > Christopher Baines writes: > >> * gnu/tests/databases.scm (%postgresql-os, %test-postgresql): New variab= les. >> (run-postgresql-test): New procedure. >> --- >> gnu/tests/databases.scm | 55 ++++++++++++++++++++++++++++++++++++++++++= +++++++ >> 1 file changed, 55 insertions(+) >> >> diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm >> index e7097690a..583f484d7 100644 >> --- a/gnu/tests/databases.scm >> +++ b/gnu/tests/databases.scm >> @@ -30,6 +30,7 @@ >> #:use-module (guix store) >> #:export (%test-memcached >> %test-mongodb >> + %test-postgresql >> %test-mysql)) >>=20=20 >> (define %memcached-os >> @@ -208,6 +209,60 @@ >> (value (run-mongodb-test)))) >>=20=20 >> >> +;;; >> +;;; The PostgreSQL service. >> +;;; >> + >> +(define %postgresql-os >> + (simple-operating-system >> + (service postgresql-service-type))) >> + >> +(define* (run-postgresql-test) > > define, instead of define* > >> + "Run tests in %POSTGRESQL-OS." >> + (define os >> + (marionette-operating-system >> + %postgresql-os >> + #:imported-modules '((gnu services herd) >> + (guix combinators)))) >> + >> + (define vm >> + (virtual-machine >> + (operating-system os) >> + (memory-size 512))) >> + >> + (define test >> + (with-imported-modules '((gnu build marionette)) >> + #~(begin >> + (use-modules (srfi srfi-11) (srfi srfi-64) > > I think srfi-11 is useless. Good spot, I'll make these changes and send some new patches. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlqdmbJfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9Xe3JQ//T2ZBUcypPItOD2GF28cp0mGmlobU9IqJwNQ8QY/ouaLk77ySzWXZh+6R MRD9BxyILanHXW4yNNWIsnWL6uOAB1r4iFALkGy6nKJywzndGEFdbN8Io5cvEwXx Mgc+v1EjA4EcWeTcxY1xOdyBUNqRAhLCy++1wGQGgVvrB8EJJF4oa4Rsi/1xtqwA 34wFuAljtxA9aOaUFiQH0w7MzG3Cqf0iPGalfaAmWtms34+U9SU0xADi5Wmb686e xkcbJqgehcF1+rpgvwD+hhqmr6k2eRs4vyUXD2sTt+r/c3x3juno8T77OS4xSFdK LsVzcUdg+0ECNsBLLPkmLRfg8yMeKuLe42ystndUardB80DIrs8BZnXZLK4uy7gi xgAah8dNV1D5A/2uOmST4+cZYo9HyJuF3Z1jkEz77v1ePm1L2119jL2awj4szlcS dsLPAMGGCQ6TjVVwv6PzWCduKx5CHGeSSAYRUtt5hJkYfknebhqWuaFl7APv4d7O CzjbB8kl8DVWmp135B6P7naPnP9LDejqFf+70bigfFipMOsCZ1sSnAdH8eiUFVYa tvRVb0uV4Cq6M6z6gAzmO/QP3qk/i/Poi1wbYoX27S4KUqPnnhRuYIa+ectt8z9d w7I20zDDcIngKiyIr2Iagk3ARphqLLHs6FEXP78eQRTStyGUp9I= =ou27 -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 14:37:23 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 19:37:23 +0000 Received: from localhost ([127.0.0.1]:46231 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esvvG-0001V2-V6 for submit@debbugs.gnu.org; Mon, 05 Mar 2018 14:37:23 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57800 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esvvE-0001Ui-Mn for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 14:37:20 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id E63DB13D06A; Mon, 5 Mar 2018 19:37:19 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id A89CA13D067 for <30701@debbugs.gnu.org>; Mon, 5 Mar 2018 19:37:19 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 2b3ad107 for <30701@debbugs.gnu.org>; Mon, 5 Mar 2018 19:37:19 +0000 (UTC) From: Christopher Baines To: 30701@debbugs.gnu.org Subject: [PATCH 2/3] tests: databases: Add a system test for PostgreSQL. Date: Mon, 5 Mar 2018 19:37:18 +0000 Message-Id: <20180305193719.28652-2-mail@cbaines.net> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180305193719.28652-1-mail@cbaines.net> References: <20180305193719.28652-1-mail@cbaines.net> X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) * gnu/tests/databases.scm (%postgresql-os, %test-postgresql): New variables. (run-postgresql-test): New procedure. --- gnu/tests/databases.scm | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/gnu/tests/databases.scm b/gnu/tests/databases.scm index e7097690a..5c8ca85c1 100644 --- a/gnu/tests/databases.scm +++ b/gnu/tests/databases.scm @@ -30,6 +30,7 @@ #:use-module (guix store) #:export (%test-memcached %test-mongodb + %test-postgresql %test-mysql)) (define %memcached-os @@ -208,6 +209,60 @@ (value (run-mongodb-test)))) +;;; +;;; The PostgreSQL service. +;;; + +(define %postgresql-os + (simple-operating-system + (service postgresql-service-type))) + +(define (run-postgresql-test) + "Run tests in %POSTGRESQL-OS." + (define os + (marionette-operating-system + %postgresql-os + #:imported-modules '((gnu services herd) + (guix combinators)))) + + (define vm + (virtual-machine + (operating-system os) + (memory-size 512))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (srfi srfi-64) + (gnu build marionette)) + + (define marionette + (make-marionette (list #$vm))) + + (mkdir #$output) + (chdir #$output) + + (test-begin "postgresql") + + (test-assert "service running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'postgres)) + marionette)) + + (test-end) + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation "postgresql-test" test)) + +(define %test-postgresql + (system-test + (name "postgresql") + (description "Start the PostgreSQL service.") + (value (run-postgresql-test)))) + + ;;; ;;; The MySQL service. ;;; -- 2.16.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 14:37:23 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 19:37:23 +0000 Received: from localhost ([127.0.0.1]:46233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esvvH-0001V4-80 for submit@debbugs.gnu.org; Mon, 05 Mar 2018 14:37:23 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57798 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esvvE-0001Uh-Mn for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 14:37:21 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id 1045213D067; Mon, 5 Mar 2018 19:37:20 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id C134613D069 for <30701@debbugs.gnu.org>; Mon, 5 Mar 2018 19:37:19 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id c0d0dca8 for <30701@debbugs.gnu.org>; Mon, 5 Mar 2018 19:37:19 +0000 (UTC) From: Christopher Baines To: 30701@debbugs.gnu.org Subject: [PATCH 3/3] services: databases: Add postgresql-configuration record exports. Date: Mon, 5 Mar 2018 19:37:19 +0000 Message-Id: <20180305193719.28652-3-mail@cbaines.net> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180305193719.28652-1-mail@cbaines.net> References: <20180305193719.28652-1-mail@cbaines.net> X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) * gnu/services/databases.scm: Export the record type, and all the field accessors. --- gnu/services/databases.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index f7d5fffd0..4c9a50a5a 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -40,7 +40,15 @@ postgresql-config-file-ident-file postgresql-config-file-extra-config + + postgresql-configuration postgresql-configuration? + postgresql-configuration-postgresql + postgresql-configuration-port + postgresql-configuration-locale + postgresql-configuration-file + postgresql-configuration-data-directory + postgresql-service postgresql-service-type -- 2.16.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 14:37:24 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 19:37:24 +0000 Received: from localhost ([127.0.0.1]:46235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esvvH-0001VC-J3 for submit@debbugs.gnu.org; Mon, 05 Mar 2018 14:37:23 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57802 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esvvF-0001Uo-Bt for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 14:37:21 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id E77AF13D069; Mon, 5 Mar 2018 19:37:20 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 8F24F13D064 for <30701@debbugs.gnu.org>; Mon, 5 Mar 2018 19:37:19 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 83649742 for <30701@debbugs.gnu.org>; Mon, 5 Mar 2018 19:37:19 +0000 (UTC) From: Christopher Baines To: 30701@debbugs.gnu.org Subject: [PATCH 1/3] services: Rework the PostgreSQL config file to use a record type. Date: Mon, 5 Mar 2018 19:37:17 +0000 Message-Id: <20180305193719.28652-1-mail@cbaines.net> X-Mailer: git-send-email 2.16.0 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) For the default config file representation. This makes it possible to more easily change the configuration file, and have dynamic content. In particular, I'm looking at adding a pid file location to the config file. * gnu/services/databases.scm (): New record type. (%default-postgres-config): Remove this, it's been replaced by the configuration file. (): Alter the default for the config file field. (postgresql-service): Alter the default value for the config-file parameter. --- gnu/services/databases.scm | 86 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 20 deletions(-) diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm index 3ca8f471f..f7d5fffd0 100644 --- a/gnu/services/databases.scm +++ b/gnu/services/databases.scm @@ -26,11 +26,20 @@ #:use-module (gnu system shadow) #:use-module (gnu packages admin) #:use-module (gnu packages databases) + #:use-module (guix store) #:use-module (guix modules) #:use-module (guix records) #:use-module (guix gexp) + #:use-module (srfi srfi-1) #:use-module (ice-9 match) - #:export (postgresql-configuration + #:export ( + postgresql-config-file + postgresql-config-file? + postgresql-config-file-log-destination + postgresql-config-file-hba-file + postgresql-config-file-ident-file + postgresql-config-file-extra-config + postgresql-configuration? postgresql-service postgresql-service-type @@ -68,6 +77,60 @@ ;;; ;;; Code: +(define %default-postgres-hba + (plain-file "pg_hba.conf" + " +local all all trust +host all all 127.0.0.1/32 trust +host all all ::1/128 trust")) + +(define %default-postgres-ident + (plain-file "pg_ident.conf" + "# MAPNAME SYSTEM-USERNAME PG-USERNAME")) + +(define-record-type* + postgresql-config-file make-postgresql-config-file + postgresql-config-file? + (log-destination postgresql-config-file-log-destination + (default "syslog")) + (hba-file postgresql-config-file-hba-file + (default %default-postgres-hba)) + (ident-file postgresql-config-file-ident-file + (default %default-postgres-ident)) + (extra-config postgresql-config-file-extra-config + (default '()))) + +(define-gexp-compiler (postgresql-config-file-compiler + (file ) system target) + (match file + (($ log-destination hba-file + ident-file extra-config) + (define (with-single-quotes string) + (if string + (list "'" string "'") + '())) + + (define contents + (append-map + (match-lambda + ((key) '()) + ((key . #f) '()) + ((key values ...) `(,key " = " ,@values "\n"))) + + `(("log_destination" ,@(with-single-quotes log-destination)) + ("hba_file" ,@(with-single-quotes hba-file)) + ("ident_file" ,@(with-single-quotes ident-file)) + ,@extra-config))) + + (gexp->derivation + "postgresql.conf" + #~(call-with-output-file (ungexp output "out") + (lambda (port) + (display + (string-append #$@contents) + port))) + #:local-build? #t)))) + (define-record-type* postgresql-configuration make-postgresql-configuration postgresql-configuration? @@ -78,27 +141,10 @@ (locale postgresql-configuration-locale (default "en_US.utf8")) (config-file postgresql-configuration-file - (default %default-postgres-config)) + (default (postgresql-config-file))) (data-directory postgresql-configuration-data-directory (default "/var/lib/postgresql/data"))) -(define %default-postgres-hba - (plain-file "pg_hba.conf" - " -local all all trust -host all all 127.0.0.1/32 trust -host all all ::1/128 trust")) - -(define %default-postgres-ident - (plain-file "pg_ident.conf" - "# MAPNAME SYSTEM-USERNAME PG-USERNAME")) - -(define %default-postgres-config - (mixed-text-file "postgresql.conf" - "log_destination = 'syslog'\n" - "hba_file = '" %default-postgres-hba "'\n" - "ident_file = '" %default-postgres-ident "'\n")) - (define %postgresql-accounts (list (user-group (name "postgres") (system? #t)) (user-account @@ -192,7 +238,7 @@ host all all ::1/128 trust")) (define* (postgresql-service #:key (postgresql postgresql) (port 5432) (locale "en_US.utf8") - (config-file %default-postgres-config) + (config-file (postgresql-config-file)) (data-directory "/var/lib/postgresql/data")) "Return a service that runs @var{postgresql}, the PostgreSQL database server. -- 2.16.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 14:37:58 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 19:37:58 +0000 Received: from localhost ([127.0.0.1]:46238 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esvvq-0001W7-2G for submit@debbugs.gnu.org; Mon, 05 Mar 2018 14:37:58 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57810 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esvvo-0001Vz-58 for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 14:37:56 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id B693513D067; Mon, 5 Mar 2018 19:37:55 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 76A4E13D064; Mon, 5 Mar 2018 19:37:55 +0000 (GMT) Received: from giedi (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id c1f0ce46; Mon, 5 Mar 2018 19:37:55 +0000 (UTC) References: <20180304191633.20262-1-mail@cbaines.net> <20180304191633.20262-4-mail@cbaines.net> <87a7vmzpht.fsf@lassieur.org> User-agent: mu4e 0.9.18; emacs 25.3.1 From: Christopher Baines To: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Subject: Re: [bug#30701] [PATCH 4/4] services: databases: Add postgresql-configuration record exports. In-reply-to: <87a7vmzpht.fsf@lassieur.org> Date: Mon, 05 Mar 2018 19:37:48 +0000 Message-ID: <87d10ipb3n.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cl=C3=A9ment Lassieur writes: > Christopher Baines writes: > >> * gnu/services/databases.scm: Export the record type, and all the field >> accessors. > ^ > Small nit-pick: there is no indentation here :-). You can check "git > log" to see how other people do. I've updated the git commit messages, and sent some updated patches. Thanks for taking a look :) --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlqdnIxfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9XcBKw//S2WJquM4R5Ig4MiI3rnBbc6qlhGVh4ciHZG+c8pmRkGCTom18LZDrLVt +nQeLwkB8IDUCFNn1WpLXl+/9Br9v+TRgoU0r18vKO3KmpxFOogWlYd0TS4uFZvY rxFQNfxpSeXvykgDbJAKh78oEuiXczqDVmtU4Hu1Tjp6C9mHiMiPPFe9Z1C3rNa7 YrD4xtnmKAz3r6WAA9Qoo95GaLcMpixvAt96ViFdNsvCmYsi0QdqKwumvL2NfZE+ hOjRjzhOYbDy5bdt65buyvFXwtIR5WPxChkR1IJl/DJoxNgG9YuT/hZtzQdP+f1D EvDOaD0q4nTS4XPMXuv92cKf4wLpWqHdmPFiXHsSZf+wzBKp0xhRS5DWE9QPBibI nr0+lZbsGWa0ofEGsbBdEKJOI/6YXp488i9h8pUeM3hlARvJmBZYDazGVjJ0Xfmz kOstomJxA9rPCdWjhvJ0IIYsMDy2+uAhTpljPl3DwkM839hLT6fRlUSJn0BlLiyq 55jHn+G6Rzg7kUKah1JY4g2i0Pwl6PodPKUx81/Lcy/u3BRDBJBrK0TxAkIVfptr 0ivpC9JvOeeSQgguMYUhPmCbQSpfxsiJbzZXsmqTo4kXS0mWDs9KElX7BSAZyWPt IY/ZdcMmyQ6N2DdgmqBAUWya6AOWcgkozuAfefEqBOvW43GOoLE= =YZK/ -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 05 16:33:57 2018 Received: (at 30701) by debbugs.gnu.org; 5 Mar 2018 21:33:57 +0000 Received: from localhost ([127.0.0.1]:46343 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esxk5-0008JC-Li for submit@debbugs.gnu.org; Mon, 05 Mar 2018 16:33:57 -0500 Received: from mail.lassieur.org ([83.152.10.219]:54892) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1esxk3-0008J2-HL for 30701@debbugs.gnu.org; Mon, 05 Mar 2018 16:33:56 -0500 Received: from rodion (88.191.118.83 [88.191.118.83]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id 63f3ae00 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Mon, 5 Mar 2018 21:33:50 +0000 (UTC) References: <87po4jpsgc.fsf@cbaines.net> <20180305193719.28652-1-mail@cbaines.net> User-agent: mu4e 1.0; emacs 25.3.1 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur To: Christopher Baines Subject: Re: [bug#30701] [PATCH 1/3] services: Rework the PostgreSQL config file to use a record type. In-reply-to: <20180305193719.28652-1-mail@cbaines.net> Date: Mon, 05 Mar 2018 22:33:49 +0100 Message-ID: <87fu5eyzpe.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701 Cc: 30701@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Christopher Baines writes: > For the default config file representation. This makes it possible to more > easily change the configuration file, and have dynamic content. In particular, > I'm looking at adding a pid file location to the config file. ^ Could you please remove this last sentence (with the pid file)? > * gnu/services/databases.scm (): New record type. > (%default-postgres-config): Remove this, it's been replaced by the > configuration file. > (): Alter the default for the config file field. > (postgresql-service): Alter the default value for the config-file parameter. > --- > gnu/services/databases.scm | 86 +++++++++++++++++++++++++++++++++++----------- > 1 file changed, 66 insertions(+), 20 deletions(-) > > diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm > index 3ca8f471f..f7d5fffd0 100644 > --- a/gnu/services/databases.scm > +++ b/gnu/services/databases.scm > @@ -26,11 +26,20 @@ > #:use-module (gnu system shadow) > #:use-module (gnu packages admin) > #:use-module (gnu packages databases) > + #:use-module (guix store) I don't think (guix store) is used. Is it? > #:use-module (guix modules) > #:use-module (guix records) > #:use-module (guix gexp) ... > + `(("log_destination" ,@(with-single-quotes log-destination)) > + ("hba_file" ,@(with-single-quotes hba-file)) > + ("ident_file" ,@(with-single-quotes ident-file)) ^ Could you please use a shorter name? Like "enclose", so that we won't go over 80 columns too easily :-). Apart from those small things, the three patches LGTM. Thank you again! Clément From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 13 13:37:38 2018 Received: (at 30701-done) by debbugs.gnu.org; 13 Mar 2018 17:37:38 +0000 Received: from localhost ([127.0.0.1]:59794 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1evnrm-0008EW-7Q for submit@debbugs.gnu.org; Tue, 13 Mar 2018 13:37:38 -0400 Received: from li622-129.members.linode.com ([212.71.249.129]:35376 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1evnri-0008EL-Dx for 30701-done@debbugs.gnu.org; Tue, 13 Mar 2018 13:37:35 -0400 Received: by mira.cbaines.net (Postfix, from userid 113) id 8F0E213D067; Tue, 13 Mar 2018 17:37:33 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 3552613D064; Tue, 13 Mar 2018 17:37:33 +0000 (GMT) Received: from giedi (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 196cf859; Tue, 13 Mar 2018 17:37:32 +0000 (UTC) References: <87po4jpsgc.fsf@cbaines.net> <20180305193719.28652-1-mail@cbaines.net> <87fu5eyzpe.fsf@lassieur.org> User-agent: mu4e 1.0; emacs 25.3.1 From: Christopher Baines To: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Subject: Re: [bug#30701] [PATCH 1/3] services: Rework the PostgreSQL config file to use a record type. In-reply-to: <87fu5eyzpe.fsf@lassieur.org> Date: Tue, 13 Mar 2018 17:37:30 +0000 Message-ID: <87605z27xh.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701-done Cc: 30701-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sorry, I made some changes, and merged these patches on the weekend, but I forgot to reply. Cl=C3=A9ment Lassieur writes: > Christopher Baines writes: > >> For the default config file representation. This makes it possible to mo= re >> easily change the configuration file, and have dynamic content. In parti= cular, >> I'm looking at adding a pid file location to the config file. > > ^ > Could you please remove this last sentence (with the pid file)? Done. >> * gnu/services/databases.scm (): New record type. >> (%default-postgres-config): Remove this, it's been replaced by the >> configuration file. >> (): Alter the default for the config file fiel= d. >> (postgresql-service): Alter the default value for the config-file parame= ter. >> --- >> gnu/services/databases.scm | 86 +++++++++++++++++++++++++++++++++++----= ------- >> 1 file changed, 66 insertions(+), 20 deletions(-) >> >> diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm >> index 3ca8f471f..f7d5fffd0 100644 >> --- a/gnu/services/databases.scm >> +++ b/gnu/services/databases.scm >> @@ -26,11 +26,20 @@ >> #:use-module (gnu system shadow) >> #:use-module (gnu packages admin) >> #:use-module (gnu packages databases) >> + #:use-module (guix store) > > I don't think (guix store) is used. Is it? It wasn't, I've removed it. >> #:use-module (guix modules) >> #:use-module (guix records) >> #:use-module (guix gexp) > > ... > >> + `(("log_destination" ,@(with-single-quotes log-destination)) >> + ("hba_file" ,@(with-single-quotes hba-file)) >> + ("ident_file" ,@(with-single-quotes ident-file)) > ^ > Could you please use a shorter name? Like "enclose", so that we won't > go over 80 columns too easily :-). I went with quote' as I think that works well. > Apart from those small things, the three patches LGTM. Thank you > again! Thanks for taking a look and for your comments :) Chris --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlqoDFpfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9XcKBBAAmojnwgpIzO3XdgVSVsHzBvYtTKGOeK7+Ez20ILVG4b6h9FGyKQOt91fY rC1Dflp7ZnyA1PUtDU7NW/YZBI8mC0mPjEiRQJJUSpHQ3hwXIHahQfuwEVeMXhqn t/f/ZelfKyYHAzP7fla44UyV0wxGxtYbaevoAIsRzf1R0W3UmLN/TEiRxrUpVPIp g+zvUiyi3H4XYJvZ4L+NZx7C0KRgX6YO4fyNnABJ1qmvQy6y1XqPlZB6En3wIGEN PgDB7vUDCGg91UIM2FgrlbwdI24g+5gOfYALw+QujXgCOQCW+x5F2S5SVpNPZegR jcxnMOw8Faqb3ObVRyRb56cjBsbykZWclWS2ozx8LeepvHJAXqmQB8ra9Tv0LTm6 731N3A8VsUc/LCfpXh1ixEZ2h86bYQ8e8G5ayY4vc9t+ydxgH9fPKywk2XUBRbd3 WsgdWk/U8Z/ElSxc7iXay2M/IADr/BeeymcQKSQeXr836caW/LsZaKsUsBCkgC1N lu6QnNVnQpamId6/VLbVdpw4RHshBSOm8sWEiiM0mbPzzGFlxzsspcTdO+liCYcD mg85GejF93o44epBbplVFSSO9QU+zyNgGgQTBdGUSghEZSaosBSmzMzUZdXfqaYG FrvWll/bayreQ8gvFEr4k/IchJ1jI/SpESAmbcNN3rzIHvMIs+c= =kdPb -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 14 13:37:46 2018 Received: (at 30701-done) by debbugs.gnu.org; 14 Mar 2018 17:37:46 +0000 Received: from localhost ([127.0.0.1]:33560 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ewALS-0005j6-3t for submit@debbugs.gnu.org; Wed, 14 Mar 2018 13:37:46 -0400 Received: from mail.lassieur.org ([83.152.10.219]:56118) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ewALP-0005iw-OZ for 30701-done@debbugs.gnu.org; Wed, 14 Mar 2018 13:37:44 -0400 Received: from newt (46.218.109.88 [46.218.109.88]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id f9effc99 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Wed, 14 Mar 2018 17:37:42 +0000 (UTC) References: <87po4jpsgc.fsf@cbaines.net> <20180305193719.28652-1-mail@cbaines.net> <87fu5eyzpe.fsf@lassieur.org> <87605z27xh.fsf@cbaines.net> User-agent: mu4e 1.0; emacs 25.3.1 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur To: Christopher Baines Subject: Re: bug#30701: [PATCH 1/3] services: Rework the PostgreSQL config file to use a record type. In-reply-to: <87605z27xh.fsf@cbaines.net> Date: Wed, 14 Mar 2018 18:37:40 +0100 Message-ID: <87o9jqtv6j.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701-done Cc: 30701-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Christopher Baines writes: > Sorry, I made some changes, and merged these patches on the weekend, but > I forgot to reply. [...] >>> + `(("log_destination" ,@(with-single-quotes log-destination)) >>> + ("hba_file" ,@(with-single-quotes hba-file)) >>> + ("ident_file" ,@(with-single-quotes ident-file)) >> ^ >> Could you please use a shorter name? Like "enclose", so that we won't >> go over 80 columns too easily :-). > > I went with quote' as I think that works well. I don't like it because: • The extra \' doesn't help describing what the function does. One could believe it's a variant of 'quote', but it's actually very different. • It doesn't follow our coding style. See https://mumble.net/~campbell/scheme/style.txt. "Symbolic names are written with English words separated by hyphens." See also the part about "Funny Characters". > Thanks for taking a look and for your comments :) You're welcome :-) Clément From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 17 16:35:09 2018 Received: (at 30701-done) by debbugs.gnu.org; 17 Mar 2018 20:35:09 +0000 Received: from localhost ([127.0.0.1]:38694 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1exIXk-0000RG-Rs for submit@debbugs.gnu.org; Sat, 17 Mar 2018 16:35:09 -0400 Received: from li622-129.members.linode.com ([212.71.249.129]:39342 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1exIXh-0000R6-Md for 30701-done@debbugs.gnu.org; Sat, 17 Mar 2018 16:35:07 -0400 Received: by mira.cbaines.net (Postfix, from userid 113) id BCC1113D067; Sat, 17 Mar 2018 20:35:04 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 6585113D064; Sat, 17 Mar 2018 20:35:04 +0000 (GMT) Received: from giedi (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 41e93885; Sat, 17 Mar 2018 20:35:03 +0000 (UTC) References: <87po4jpsgc.fsf@cbaines.net> <20180305193719.28652-1-mail@cbaines.net> <87fu5eyzpe.fsf@lassieur.org> <87605z27xh.fsf@cbaines.net> <87o9jqtv6j.fsf@lassieur.org> User-agent: mu4e 1.0; emacs 25.3.1 From: Christopher Baines To: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Subject: Re: bug#30701: [PATCH 1/3] services: Rework the PostgreSQL config file to use a record type. In-reply-to: <87o9jqtv6j.fsf@lassieur.org> Date: Sat, 17 Mar 2018 20:35:03 +0000 Message-ID: <87605ujv9k.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701-done Cc: 30701-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cl=C3=A9ment Lassieur writes: > Christopher Baines writes: > >> Sorry, I made some changes, and merged these patches on the weekend, but >> I forgot to reply. > > [...] > >>>> + `(("log_destination" ,@(with-single-quotes log-destination)) >>>> + ("hba_file" ,@(with-single-quotes hba-file)) >>>> + ("ident_file" ,@(with-single-quotes ident-file)) >>> ^ >>> Could you please use a shorter name? Like "enclose", so that we won't >>> go over 80 columns too easily :-). >> >> I went with quote' as I think that works well. > > I don't like it because: > > =E2=80=A2 The extra \' doesn't help describing what the function does. = One > could believe it's a variant of 'quote', but it's actually very > different. > > =E2=80=A2 It doesn't follow our coding style. See > https://mumble.net/~campbell/scheme/style.txt. "Symbolic names are > written with English words separated by hyphens." See also the part > about "Funny Characters". Fair enough, I've changed it to single-quote in 533808383f7fca6563aee1452f5202e0cd1b66b8. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlqte/dfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9XcoBQ/9GO/M1sPFvNRFo2IebyOsOP4p02Hymzm/s43Li9ElbMXM44eO+7OE4wJD Ht36t1S9o33rymGOludv4mHn6JQipzg0ofWLTgsVfBqWVJ3YZGsNXq3kqMBxzN6w RvuRK/J5HSjNOZcshclllN85uDeKx6t4FiQLHkwLTRV1JC7bX6tHMwYgk4L6LPrs MIsjzZcq65+IzdlWWZyy/ZM9WrQhD8a3WE2jNwB5WZ3TmFEKtFBP2g7nui1TUk/l 5GOh4EYBkN9hMe7xFfJGKgaxI03bylLdHWCNpG3woowF5/tFdc1q4xvVUX+dVnZe kdGT9QDhm+/jhV3FMiC8ODB8VIQgzt2lJ8zKjVspoBD11WQqf/FjT+1M5sERRLnd RpvDjKmhMcbAGWy9vU7wu8/TG9ZjI8AGj5R1poZJOQ15dBcBY5SAMMs5b/dbvgRp 7O8aDO7V79dMGrQqx9IpUdmFJT2rmnWy/l/pUkitw6Oh9+yjsVEhs5q9pk1msMfk ++lZ9b0UjFcik00CF2XJ/R8yijCNsi4RDv9FpyF0rPlEWyltBwUb5MGHEeEHOf/S HAtbozuig1NMhzDE1V7K8MU+pF/fGGjlNdfQIaFZp2W8r2fJuCztfulG6TqPT9Qc 4JUgiRWE2swPIpTakXfLhCjTyHsRhDt803QgHH5P/JqjbEFENdE= =nMnK -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 17 20:34:59 2018 Received: (at 30701-done) by debbugs.gnu.org; 18 Mar 2018 00:34:59 +0000 Received: from localhost ([127.0.0.1]:38874 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1exMHq-0001ig-Qy for submit@debbugs.gnu.org; Sat, 17 Mar 2018 20:34:59 -0400 Received: from mail.lassieur.org ([83.152.10.219]:56396) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1exMHm-0001iT-5k for 30701-done@debbugs.gnu.org; Sat, 17 Mar 2018 20:34:54 -0400 Received: from rodion (192.168.0.254 [192.168.0.254]) by mail.lassieur.org (OpenSMTPD) with ESMTPSA id 8cbf683d (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Sun, 18 Mar 2018 00:34:49 +0000 (UTC) References: <87po4jpsgc.fsf@cbaines.net> <20180305193719.28652-1-mail@cbaines.net> <87fu5eyzpe.fsf@lassieur.org> <87605z27xh.fsf@cbaines.net> <87o9jqtv6j.fsf@lassieur.org> <87605ujv9k.fsf@cbaines.net> User-agent: mu4e 1.0; emacs 25.3.1 From: =?utf-8?Q?Cl=C3=A9ment?= Lassieur To: Christopher Baines Subject: Re: [bug#30701] [PATCH 1/3] services: Rework the PostgreSQL config file to use a record type. In-reply-to: <87605ujv9k.fsf@cbaines.net> Date: Sun, 18 Mar 2018 01:34:48 +0100 Message-ID: <87fu4yfcgn.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30701-done Cc: 30701-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Christopher Baines writes: > Clément Lassieur writes: > >> Christopher Baines writes: >> >>> Sorry, I made some changes, and merged these patches on the weekend, but >>> I forgot to reply. >> >> [...] >> >>>>> + `(("log_destination" ,@(with-single-quotes log-destination)) >>>>> + ("hba_file" ,@(with-single-quotes hba-file)) >>>>> + ("ident_file" ,@(with-single-quotes ident-file)) >>>> ^ >>>> Could you please use a shorter name? Like "enclose", so that we won't >>>> go over 80 columns too easily :-). >>> >>> I went with quote' as I think that works well. >> >> I don't like it because: >> >> • The extra \' doesn't help describing what the function does. One >> could believe it's a variant of 'quote', but it's actually very >> different. >> >> • It doesn't follow our coding style. See >> https://mumble.net/~campbell/scheme/style.txt. "Symbolic names are >> written with English words separated by hyphens." See also the part >> about "Funny Characters". > > Fair enough, I've changed it to single-quote in > 533808383f7fca6563aee1452f5202e0cd1b66b8. Thank you Christopher! From unknown Fri Aug 15 17:19:04 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 15 Apr 2018 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator