From unknown Mon Aug 18 09:06:47 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#29466] [PATCH] services: web: Add support for configuring the nginx server names hash. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 27 Nov 2017 08:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 29466 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 29466@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.15117710423028 (code B ref -1); Mon, 27 Nov 2017 08:25:01 +0000 Received: (at submit) by debbugs.gnu.org; 27 Nov 2017 08:24:02 +0000 Received: from localhost ([127.0.0.1]:59996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJEhu-0000mm-B6 for submit@debbugs.gnu.org; Mon, 27 Nov 2017 03:24:02 -0500 Received: from eggs.gnu.org ([208.118.235.92]:42046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJEhs-0000mH-4G for submit@debbugs.gnu.org; Mon, 27 Nov 2017 03:24:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJEhh-00038k-2F for submit@debbugs.gnu.org; Mon, 27 Nov 2017 03:23:54 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42395) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eJEhg-00038g-W0 for submit@debbugs.gnu.org; Mon, 27 Nov 2017 03:23:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJEhe-0005jR-1w for guix-patches@gnu.org; Mon, 27 Nov 2017 03:23:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJEhZ-00036r-2i for guix-patches@gnu.org; Mon, 27 Nov 2017 03:23:46 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:52552 helo=mira.cbaines.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJEhY-00036R-QX for guix-patches@gnu.org; Mon, 27 Nov 2017 03:23:41 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id D769913E81A; Mon, 27 Nov 2017 08:23:38 +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 9D96913E819 for ; Mon, 27 Nov 2017 08:23:38 +0000 (GMT) Received: from localhost.localdomain (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 19b0b87f for ; Mon, 27 Nov 2017 08:23:38 +0000 (UTC) From: Christopher Baines Date: Mon, 27 Nov 2017 08:23:38 +0000 Message-Id: <20171127082338.18504-1-mail@cbaines.net> X-Mailer: git-send-email 2.14.2 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-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 (----) The nginx service can fail to start if the server names hash bucket size is too small, which can happen on some systems, and when using QEMU, depending on the CPU. * gnu/services/web.scm (): Add server-names-hash-bucket-size and server-names-hash-bucket-max-size. (default-nginx-config): Add support for the new hash bucket size parameters. (nginx-service, nginx-activation): Pass the new hash bucket size parameters through to the default-nginx-config procedure. * doc/guix.texi (Web Services): Document the new hash bucket size parameters. --- doc/guix.texi | 7 +++++++ gnu/services/web.scm | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 2a6825682..d0a00bdcb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14874,6 +14874,13 @@ This can be useful if you have an existing configuration file, or it's not possible to do what is required through the other parts of the nginx-configuration record. +@item @code{server-names-hash-bucket-size} (default: @code{#f}) +Bucket size for the server names hash tables, defaults to @code{#f} to +use the size of the processors cache line. + +@item @code{server-names-hash-bucket-max-size} (default: @code{#f}) +Maximum bucket size for the server names hash tables. + @end table @end deffn diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 9d713003c..b9acee762 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -38,6 +38,8 @@ nginx-configuration-run-directory nginx-configuration-server-blocks nginx-configuration-upstream-blocks + nginx-configuration-server-names-hash-bucket-size + nginx-configuration-server-names-hash-bucket-max-size nginx-configuration-file @@ -141,6 +143,10 @@ (default '())) ;list of (upstream-blocks nginx-configuration-upstream-blocks (default '())) ;list of + (server-names-hash-bucket-size nginx-configuration-server-names-hash-bucket-size + (default #f)) + (server-names-hash-bucket-max-size nginx-configuration-server-names-hash-bucket-max-size + (default #f)) (file nginx-configuration-file ;#f | string | file-like (default #f))) @@ -235,7 +241,9 @@ of index files." (cons head out))) (fold-right flatten1 '() lst)) -(define (default-nginx-config nginx log-directory run-directory server-list upstream-list) +(define (default-nginx-config nginx log-directory run-directory server-list + upstream-list server-names-hash-bucket-size + server-names-hash-bucket-max-size) (apply mixed-text-file "nginx.conf" (flatten "user nginx nginx;\n" @@ -249,6 +257,18 @@ of index files." " scgi_temp_path " run-directory "/scgi_temp;\n" " access_log " log-directory "/access.log;\n" " include " nginx "/share/nginx/conf/mime.types;\n" + (if server-names-hash-bucket-size + (string-append + " server_names_hash_bucket_size " + (number->string server-names-hash-bucket-size) + ";\n") + "") + (if server-names-hash-bucket-max-size + (string-append + " server_names_hash_bucket_max_size " + (number->string server-names-hash-bucket-max-size) + ";\n") + "") "\n" (map emit-nginx-upstream-config upstream-list) (map emit-nginx-server-config server-list) @@ -268,7 +288,8 @@ of index files." (define nginx-activation (match-lambda (($ nginx log-directory run-directory server-blocks - upstream-blocks file) + upstream-blocks server-names-hash-bucket-size + server-names-hash-bucket-max-size file) #~(begin (use-modules (guix build utils)) @@ -289,13 +310,16 @@ of index files." (system* (string-append #$nginx "/sbin/nginx") "-c" #$(or file (default-nginx-config nginx log-directory - run-directory server-blocks upstream-blocks)) + run-directory server-blocks upstream-blocks + server-names-hash-bucket-size + server-names-hash-bucket-max-size)) "-t"))))) (define nginx-shepherd-service (match-lambda (($ nginx log-directory run-directory server-blocks - upstream-blocks file) + upstream-blocks server-names-hash-bucket-size + server-names-hash-bucket-max-size file) (let* ((nginx-binary (file-append nginx "/sbin/nginx")) (nginx-action (lambda args @@ -304,7 +328,9 @@ of index files." (system* #$nginx-binary "-c" #$(or file (default-nginx-config nginx log-directory - run-directory server-blocks upstream-blocks)) + run-directory server-blocks upstream-blocks + server-names-hash-bucket-size + server-names-hash-bucket-max-size)) #$@args)))))) ;; TODO: Add 'reload' action. -- 2.14.2 From unknown Mon Aug 18 09:06:47 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#29466] [PATCH] services: web: Add support for configuring the nginx server names hash. Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 27 Nov 2017 14:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29466 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Christopher Baines Cc: 29466@debbugs.gnu.org Received: via spool by 29466-submit@debbugs.gnu.org id=B29466.151179161310002 (code B ref 29466); Mon, 27 Nov 2017 14:07:02 +0000 Received: (at 29466) by debbugs.gnu.org; 27 Nov 2017 14:06:53 +0000 Received: from localhost ([127.0.0.1]:60229 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJK3h-0002bG-8r for submit@debbugs.gnu.org; Mon, 27 Nov 2017 09:06:53 -0500 Received: from [141.255.128.1] (port=50534 helo=hera.aquilenet.fr) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJK3f-0002b8-7n for 29466@debbugs.gnu.org; Mon, 27 Nov 2017 09:06:51 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 52367F438; Mon, 27 Nov 2017 15:06:53 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BB9MfTULGSrB; Mon, 27 Nov 2017 15:06:52 +0100 (CET) Received: from ribbon (nat-eduroam-36-gw-01-bso.bordeaux.inria.fr [194.199.1.36]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 9CA64EF69; Mon, 27 Nov 2017 15:06:52 +0100 (CET) From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20171127082338.18504-1-mail@cbaines.net> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 7 Frimaire an 226 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Mon, 27 Nov 2017 15:06:48 +0100 In-Reply-To: <20171127082338.18504-1-mail@cbaines.net> (Christopher Baines's message of "Mon, 27 Nov 2017 08:23:38 +0000") Message-ID: <87zi77lssn.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 2.2 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi! Christopher Baines skribis: > The nginx service can fail to start if the server names hash bucket size is > too small, which can happen on some systems, and when using QEMU, depending on > the CPU. > > * gnu/services/web.scm (): Add > server-names-hash-bucket-size and server-names-hash-bucket-max-size. > (default-nginx-config): Add support for the new hash bucket size parameters. > (nginx-service, nginx-activation): Pass the new hash bucket size parameters > through to the default-nginx-config procedure. > * doc/guix.texi (Web Services): Document the new hash bucket size parameters. [...] Content analysis details: (2.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_FAIL SPF: HELO does not match SPF record (fail) [SPF failed: Please see http://www.openspf.org/Why?s=helo; id=hera.aquilenet.fr; ip=141.255.128.1; r=debbugs.gnu.org] 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS 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: 2.2 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi! Christopher Baines skribis: > The nginx service can fail to start if the server names hash bucket size is > too small, which can happen on some systems, and when using QEMU, depending on > the CPU. > > * gnu/services/web.scm (): Add > server-names-hash-bucket-size and server-names-hash-bucket-max-size. > (default-nginx-config): Add support for the new hash bucket size parameters. > (nginx-service, nginx-activation): Pass the new hash bucket size parameters > through to the default-nginx-config procedure. > * doc/guix.texi (Web Services): Document the new hash bucket size parameters. [...] Content analysis details: (2.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_FAIL SPF: HELO does not match SPF record (fail) [SPF failed: Please see http://www.openspf.org/Why?s=helo;id=hera.aquilenet.fr;ip=141.255.128.1;r=debbugs.gnu.org] 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS Hi! Christopher Baines skribis: > The nginx service can fail to start if the server names hash bucket size = is > too small, which can happen on some systems, and when using QEMU, dependi= ng on > the CPU. > > * gnu/services/web.scm (): Add > server-names-hash-bucket-size and server-names-hash-bucket-max-size. > (default-nginx-config): Add support for the new hash bucket size parame= ters. > (nginx-service, nginx-activation): Pass the new hash bucket size parame= ters > through to the default-nginx-config procedure. > * doc/guix.texi (Web Services): Document the new hash bucket size paramet= ers. LGTM! However=E2=80=A6 > -(define (default-nginx-config nginx log-directory run-directory server-l= ist upstream-list) > +(define (default-nginx-config nginx log-directory run-directory server-l= ist > + upstream-list server-names-hash-bucket-size > + server-names-hash-bucket-max-size) That=E2=80=99s too many positional parameters. And should we use a gexp compiler for anyway? > (define nginx-shepherd-service > (match-lambda > (($ nginx log-directory run-directory server-b= locks > - upstream-blocks file) > + upstream-blocks server-names-hash-bucket-s= ize > + server-names-hash-bucket-max-size file) Likewise, at this stage, we should probably use =E2=80=98match-record=E2=80= =99 to avoid mistakes. Thanks, Ludo=E2=80=99. From unknown Mon Aug 18 09:06:47 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#29466] [PATCH 1/2] services: web: Switch nginx related functions to use match-record. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 10 Dec 2017 08:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29466 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 29466@debbugs.gnu.org Received: via spool by 29466-submit@debbugs.gnu.org id=B29466.151289546712049 (code B ref 29466); Sun, 10 Dec 2017 08:45:02 +0000 Received: (at 29466) by debbugs.gnu.org; 10 Dec 2017 08:44:27 +0000 Received: from localhost ([127.0.0.1]:54464 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNxDm-00038G-Ig for submit@debbugs.gnu.org; Sun, 10 Dec 2017 03:44:26 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:56988 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNxDk-000382-5u for 29466@debbugs.gnu.org; Sun, 10 Dec 2017 03:44:24 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id A7F1313E8A9; Sun, 10 Dec 2017 08:44:22 +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 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 59ABE13E351 for <29466@debbugs.gnu.org>; Sun, 10 Dec 2017 08:44:22 +0000 (GMT) Received: from localhost.localdomain (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 8f370f5f for <29466@debbugs.gnu.org>; Sun, 10 Dec 2017 08:44:22 +0000 (UTC) From: Christopher Baines Date: Sun, 10 Dec 2017 08:44:20 +0000 Message-Id: <20171210084421.26404-1-mail@cbaines.net> X-Mailer: git-send-email 2.15.1 In-Reply-To: <87zi77lssn.fsf@gnu.org> References: <87zi77lssn.fsf@gnu.org> X-Spam-Score: -0.0 (/) 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 (/) As this is less prone to mistakes than match. * gnu/services/web.scm (default-nginx-config, nginx-activation, nginx-shepherd-service): Switch from using match-lambda to match-record. --- gnu/services/web.scm | 166 +++++++++++++++++++++++++-------------------------- 1 file changed, 81 insertions(+), 85 deletions(-) diff --git a/gnu/services/web.scm b/gnu/services/web.scm index b9acee762..477e43e8d 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -241,39 +241,43 @@ of index files." (cons head out))) (fold-right flatten1 '() lst)) -(define (default-nginx-config nginx log-directory run-directory server-list - upstream-list server-names-hash-bucket-size - server-names-hash-bucket-max-size) - (apply mixed-text-file "nginx.conf" - (flatten - "user nginx nginx;\n" - "pid " run-directory "/pid;\n" - "error_log " log-directory "/error.log info;\n" - "http {\n" - " client_body_temp_path " run-directory "/client_body_temp;\n" - " proxy_temp_path " run-directory "/proxy_temp;\n" - " fastcgi_temp_path " run-directory "/fastcgi_temp;\n" - " uwsgi_temp_path " run-directory "/uwsgi_temp;\n" - " scgi_temp_path " run-directory "/scgi_temp;\n" - " access_log " log-directory "/access.log;\n" - " include " nginx "/share/nginx/conf/mime.types;\n" - (if server-names-hash-bucket-size - (string-append - " server_names_hash_bucket_size " - (number->string server-names-hash-bucket-size) - ";\n") - "") - (if server-names-hash-bucket-max-size - (string-append - " server_names_hash_bucket_max_size " - (number->string server-names-hash-bucket-max-size) - ";\n") - "") - "\n" - (map emit-nginx-upstream-config upstream-list) - (map emit-nginx-server-config server-list) - "}\n" - "events {}\n"))) +(define (default-nginx-config config) + (match-record config + + (nginx log-directory run-directory + server-blocks upstream-blocks + server-names-hash-bucket-size + server-names-hash-bucket-max-size) + (apply mixed-text-file "nginx.conf" + (flatten + "user nginx nginx;\n" + "pid " run-directory "/pid;\n" + "error_log " log-directory "/error.log info;\n" + "http {\n" + " client_body_temp_path " run-directory "/client_body_temp;\n" + " proxy_temp_path " run-directory "/proxy_temp;\n" + " fastcgi_temp_path " run-directory "/fastcgi_temp;\n" + " uwsgi_temp_path " run-directory "/uwsgi_temp;\n" + " scgi_temp_path " run-directory "/scgi_temp;\n" + " access_log " log-directory "/access.log;\n" + " include " nginx "/share/nginx/conf/mime.types;\n" + (if server-names-hash-bucket-size + (string-append + " server_names_hash_bucket_size " + (number->string server-names-hash-bucket-size) + ";\n") + "") + (if server-names-hash-bucket-max-size + (string-append + " server_names_hash_bucket_max_size " + (number->string server-names-hash-bucket-max-size) + ";\n") + "") + "\n" + (map emit-nginx-upstream-config upstream-blocks) + (map emit-nginx-server-config server-blocks) + "}\n" + "events {}\n")))) (define %nginx-accounts (list (user-group (name "nginx") (system? #t)) @@ -285,61 +289,53 @@ of index files." (home-directory "/var/empty") (shell (file-append shadow "/sbin/nologin"))))) -(define nginx-activation - (match-lambda - (($ nginx log-directory run-directory server-blocks - upstream-blocks server-names-hash-bucket-size - server-names-hash-bucket-max-size file) - #~(begin - (use-modules (guix build utils)) +(define (nginx-activation config) + (match-record config + + (nginx log-directory run-directory file) + #~(begin + (use-modules (guix build utils)) - (format #t "creating nginx log directory '~a'~%" #$log-directory) - (mkdir-p #$log-directory) - (format #t "creating nginx run directory '~a'~%" #$run-directory) - (mkdir-p #$run-directory) - (format #t "creating nginx temp directories '~a/{client_body,proxy,fastcgi,uwsgi,scgi}_temp'~%" #$run-directory) - (mkdir-p (string-append #$run-directory "/client_body_temp")) - (mkdir-p (string-append #$run-directory "/proxy_temp")) - (mkdir-p (string-append #$run-directory "/fastcgi_temp")) - (mkdir-p (string-append #$run-directory "/uwsgi_temp")) - (mkdir-p (string-append #$run-directory "/scgi_temp")) - ;; Start-up logs. Once configuration is loaded, nginx switches to - ;; log-directory. - (mkdir-p (string-append #$run-directory "/logs")) - ;; Check configuration file syntax. - (system* (string-append #$nginx "/sbin/nginx") - "-c" #$(or file - (default-nginx-config nginx log-directory - run-directory server-blocks upstream-blocks - server-names-hash-bucket-size - server-names-hash-bucket-max-size)) - "-t"))))) + (format #t "creating nginx log directory '~a'~%" #$log-directory) + (mkdir-p #$log-directory) + (format #t "creating nginx run directory '~a'~%" #$run-directory) + (mkdir-p #$run-directory) + (format #t "creating nginx temp directories '~a/{client_body,proxy,fastcgi,uwsgi,scgi}_temp'~%" #$run-directory) + (mkdir-p (string-append #$run-directory "/client_body_temp")) + (mkdir-p (string-append #$run-directory "/proxy_temp")) + (mkdir-p (string-append #$run-directory "/fastcgi_temp")) + (mkdir-p (string-append #$run-directory "/uwsgi_temp")) + (mkdir-p (string-append #$run-directory "/scgi_temp")) + ;; Start-up logs. Once configuration is loaded, nginx switches to + ;; log-directory. + (mkdir-p (string-append #$run-directory "/logs")) + ;; Check configuration file syntax. + (system* (string-append #$nginx "/sbin/nginx") + "-c" #$(or file + (default-nginx-config config)) + "-t")))) -(define nginx-shepherd-service - (match-lambda - (($ nginx log-directory run-directory server-blocks - upstream-blocks server-names-hash-bucket-size - server-names-hash-bucket-max-size file) - (let* ((nginx-binary (file-append nginx "/sbin/nginx")) - (nginx-action - (lambda args - #~(lambda _ - (zero? - (system* #$nginx-binary "-c" - #$(or file - (default-nginx-config nginx log-directory - run-directory server-blocks upstream-blocks - server-names-hash-bucket-size - server-names-hash-bucket-max-size)) - #$@args)))))) +(define (nginx-shepherd-service config) + (match-record config + + (nginx file run-directory) + (let* ((nginx-binary (file-append nginx "/sbin/nginx")) + (nginx-action + (lambda args + #~(lambda _ + (zero? + (system* #$nginx-binary "-c" + #$(or file + (default-nginx-config config)) + #$@args)))))) - ;; TODO: Add 'reload' action. - (list (shepherd-service - (provision '(nginx)) - (documentation "Run the nginx daemon.") - (requirement '(user-processes loopback)) - (start (nginx-action "-p" run-directory)) - (stop (nginx-action "-s" "stop")))))))) + ;; TODO: Add 'reload' action. + (list (shepherd-service + (provision '(nginx)) + (documentation "Run the nginx daemon.") + (requirement '(user-processes loopback)) + (start (nginx-action "-p" run-directory)) + (stop (nginx-action "-s" "stop"))))))) (define nginx-service-type (service-type (name 'nginx) -- 2.15.1 From unknown Mon Aug 18 09:06:47 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#29466] [PATCH 2/2] WIP: Split the config file out of the record. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 10 Dec 2017 08:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29466 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 29466@debbugs.gnu.org Received: via spool by 29466-submit@debbugs.gnu.org id=B29466.151289546712055 (code B ref 29466); Sun, 10 Dec 2017 08:45:02 +0000 Received: (at 29466) by debbugs.gnu.org; 10 Dec 2017 08:44:27 +0000 Received: from localhost ([127.0.0.1]:54466 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNxDm-00038I-Vh for submit@debbugs.gnu.org; Sun, 10 Dec 2017 03:44:27 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:56986 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNxDk-000381-5u for 29466@debbugs.gnu.org; Sun, 10 Dec 2017 03:44:25 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id AFE2A13E351; Sun, 10 Dec 2017 08:44:22 +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 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 6C4D213E8A8 for <29466@debbugs.gnu.org>; Sun, 10 Dec 2017 08:44:22 +0000 (GMT) Received: from localhost.localdomain (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 6a81fa00 for <29466@debbugs.gnu.org>; Sun, 10 Dec 2017 08:44:22 +0000 (UTC) From: Christopher Baines Date: Sun, 10 Dec 2017 08:44:21 +0000 Message-Id: <20171210084421.26404-2-mail@cbaines.net> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171210084421.26404-1-mail@cbaines.net> References: <87zi77lssn.fsf@gnu.org> <20171210084421.26404-1-mail@cbaines.net> X-Spam-Score: -0.0 (/) 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/web.scm | 152 +++++++++++++++++++++++++++++++-------------------- gnu/tests/web.scm | 5 +- 2 files changed, 95 insertions(+), 62 deletions(-) diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 477e43e8d..f11ac6817 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -33,14 +33,21 @@ #:export ( nginx-configuration nginx-configuration? - nginx-configuartion-nginx + nginx-configuration-nginx nginx-configuration-log-directory nginx-configuration-run-directory - nginx-configuration-server-blocks - nginx-configuration-upstream-blocks - nginx-configuration-server-names-hash-bucket-size - nginx-configuration-server-names-hash-bucket-max-size - nginx-configuration-file + nginx-configuration-config-file + + + nginx-config-file + nginx-config-file? + nginx-config-file-nginx + nginx-config-file-log-directory + nginx-config-file-run-directory + nginx-config-file-server-blocks + nginx-config-file-upstream-blocks + nginx-config-file-server-names-hash-bucket-size + nginx-config-file-server-names-hash-bucket-max-size nginx-server-configuration @@ -130,6 +137,24 @@ (default #f)) (body nginx-named-location-configuration-body)) +(define-record-type* + nginx-config-file make-nginx-config-file + nginx-config-file? + (nginx nginx-configuration-nginx ; + (default nginx)) + (log-directory nginx-config-file-log-directory ;string + (default "/var/log/nginx")) + (run-directory nginx-config-file-run-directory ;string + (default "/var/run/nginx")) + (server-blocks nginx-config-file-server-blocks + (default '())) ;list of + (upstream-blocks nginx-config-file-upstream-blocks + (default '())) ;list of + (server-names-hash-bucket-size nginx-config-file-server-names-hash-bucket-size + (default #f)) + (server-names-hash-bucket-max-size nginx-config-file-server-names-hash-bucket-max-size + (default #f))) + (define-record-type* nginx-configuration make-nginx-configuration nginx-configuration? @@ -139,16 +164,9 @@ (default "/var/log/nginx")) (run-directory nginx-configuration-run-directory ;string (default "/var/run/nginx")) - (server-blocks nginx-configuration-server-blocks - (default '())) ;list of - (upstream-blocks nginx-configuration-upstream-blocks - (default '())) ;list of - (server-names-hash-bucket-size nginx-configuration-server-names-hash-bucket-size - (default #f)) - (server-names-hash-bucket-max-size nginx-configuration-server-names-hash-bucket-max-size - (default #f)) - (file nginx-configuration-file ;#f | string | file-like - (default #f))) + (config-file nginx-configuration-config-file ;string | file-like + (default (nginx-config-file)))) + (define (config-domain-strings names) "Return a string denoting the nginx config representation of NAMES, a list @@ -241,43 +259,49 @@ of index files." (cons head out))) (fold-right flatten1 '() lst)) -(define (default-nginx-config config) +(define-gexp-compiler (nginx-config-file-compiler + (config ) system target) (match-record config - + (nginx log-directory run-directory server-blocks upstream-blocks server-names-hash-bucket-size server-names-hash-bucket-max-size) - (apply mixed-text-file "nginx.conf" - (flatten - "user nginx nginx;\n" - "pid " run-directory "/pid;\n" - "error_log " log-directory "/error.log info;\n" - "http {\n" - " client_body_temp_path " run-directory "/client_body_temp;\n" - " proxy_temp_path " run-directory "/proxy_temp;\n" - " fastcgi_temp_path " run-directory "/fastcgi_temp;\n" - " uwsgi_temp_path " run-directory "/uwsgi_temp;\n" - " scgi_temp_path " run-directory "/scgi_temp;\n" - " access_log " log-directory "/access.log;\n" - " include " nginx "/share/nginx/conf/mime.types;\n" - (if server-names-hash-bucket-size - (string-append - " server_names_hash_bucket_size " - (number->string server-names-hash-bucket-size) - ";\n") - "") - (if server-names-hash-bucket-max-size - (string-append - " server_names_hash_bucket_max_size " - (number->string server-names-hash-bucket-max-size) - ";\n") - "") - "\n" - (map emit-nginx-upstream-config upstream-blocks) - (map emit-nginx-server-config server-blocks) + (gexp->derivation + "nginx.conf" + #~(call-with-output-file (ungexp output "out") + (lambda (port) + (display + (string-append + "user nginx nginx;\n" + "pid " #$run-directory "/pid;\n" + "error_log " #$log-directory "/error.log info;\n" + "http {\n" + " client_body_temp_path " #$run-directory "/client_body_temp;\n" + " proxy_temp_path " #$run-directory "/proxy_temp;\n" + " fastcgi_temp_path " #$run-directory "/fastcgi_temp;\n" + " uwsgi_temp_path " #$run-directory "/uwsgi_temp;\n" + " scgi_temp_path " #$run-directory "/scgi_temp;\n" + " access_log " #$log-directory "/access.log;\n" + " include " #$nginx "/share/nginx/conf/mime.types;\n" + #$(if server-names-hash-bucket-size + (string-append + " server_names_hash_bucket_size " + (number->string server-names-hash-bucket-size) + ";\n") + "") + #$(if server-names-hash-bucket-max-size + (string-append + " server_names_hash_bucket_max_size " + (number->string server-names-hash-bucket-max-size) + ";\n") + "") + "\n" + #$@(flatten (map emit-nginx-upstream-config upstream-blocks)) + #$@(flatten (map emit-nginx-server-config server-blocks)) "}\n" - "events {}\n")))) + "events {}\n") + port)))))) (define %nginx-accounts (list (user-group (name "nginx") (system? #t)) @@ -292,7 +316,7 @@ of index files." (define (nginx-activation config) (match-record config - (nginx log-directory run-directory file) + (nginx log-directory run-directory config-file) #~(begin (use-modules (guix build utils)) @@ -311,22 +335,20 @@ of index files." (mkdir-p (string-append #$run-directory "/logs")) ;; Check configuration file syntax. (system* (string-append #$nginx "/sbin/nginx") - "-c" #$(or file - (default-nginx-config config)) - "-t")))) + "-c" #$config-file + "-t")))) (define (nginx-shepherd-service config) (match-record config - (nginx file run-directory) + (nginx config-file run-directory) (let* ((nginx-binary (file-append nginx "/sbin/nginx")) (nginx-action (lambda args #~(lambda _ (zero? - (system* #$nginx-binary "-c" - #$(or file - (default-nginx-config config)) + (system* #$nginx-binary + "-c" #$config-file #$@args)))))) ;; TODO: Add 'reload' action. @@ -347,12 +369,22 @@ of index files." (service-extension account-service-type (const %nginx-accounts)))) (compose concatenate) - (extend (lambda (config servers) - (nginx-configuration - (inherit config) + (extend + (lambda (config servers) + (let ((config-file + (nginx-configuration-config-file config))) + (if (nginx-config-file? config-file) + (nginx-configuration + (inherit config) + (config-file + (nginx-config-file + (inherit config-file) (server-blocks - (append (nginx-configuration-server-blocks config) - servers))))) + (append (nginx-config-file-server-blocks config-file) + servers))))) + (unless (null? servers) + (display "warning: cannot extend nginx with a custom config file\n") + config))))) (default-value (nginx-configuration)))) diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm index 3fa272c67..06776b2dd 100644 --- a/gnu/tests/web.scm +++ b/gnu/tests/web.scm @@ -56,8 +56,9 @@ (dhcp-client-service) (service nginx-service-type (nginx-configuration - (log-directory "/var/log/nginx") - (server-blocks %nginx-servers))) + (config-file + (nginx-config-file + (server-blocks %nginx-servers))))) (simple-service 'make-http-root activation-service-type %make-http-root))) -- 2.15.1 From unknown Mon Aug 18 09:06:47 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#29466] [PATCH] services: web: Add support for configuring the nginx server names hash. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 10 Dec 2017 09:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29466 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 29466@debbugs.gnu.org Received: via spool by 29466-submit@debbugs.gnu.org id=B29466.151289643413543 (code B ref 29466); Sun, 10 Dec 2017 09:01:02 +0000 Received: (at 29466) by debbugs.gnu.org; 10 Dec 2017 09:00:34 +0000 Received: from localhost ([127.0.0.1]:54475 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNxTO-0003WN-J8 for submit@debbugs.gnu.org; Sun, 10 Dec 2017 04:00:34 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:57006 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNxTN-0003WF-3t for 29466@debbugs.gnu.org; Sun, 10 Dec 2017 04:00:33 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id A1D4F13E8A8; Sun, 10 Dec 2017 09:00:31 +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 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 5E5D913E351; Sun, 10 Dec 2017 09:00:31 +0000 (GMT) Received: from giedi (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 00616c0f; Sun, 10 Dec 2017 09:00:31 +0000 (UTC) References: <20171127082338.18504-1-mail@cbaines.net> <87zi77lssn.fsf@gnu.org> User-agent: mu4e 0.9.18; emacs 25.3.1 From: Christopher Baines In-reply-to: <87zi77lssn.fsf@gnu.org> Date: Sun, 10 Dec 2017 09:00:28 +0000 Message-ID: <87374j6jpv.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-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 Ludovic Court=C3=A8s writes: >> The nginx service can fail to start if the server names hash bucket size= is >> too small, which can happen on some systems, and when using QEMU, depend= ing on >> the CPU. >> >> * gnu/services/web.scm (): Add >> server-names-hash-bucket-size and server-names-hash-bucket-max-size. >> (default-nginx-config): Add support for the new hash bucket size param= eters. >> (nginx-service, nginx-activation): Pass the new hash bucket size param= eters >> through to the default-nginx-config procedure. >> * doc/guix.texi (Web Services): Document the new hash bucket size parame= ters. > > LGTM! > > However=E2=80=A6 > >> -(define (default-nginx-config nginx log-directory run-directory server-= list upstream-list) >> +(define (default-nginx-config nginx log-directory run-directory server-= list >> + upstream-list server-names-hash-bucket-si= ze >> + server-names-hash-bucket-max-size) > > That=E2=80=99s too many positional parameters. And should we use a gexp > compiler for anyway? > >> (define nginx-shepherd-service >> (match-lambda >> (($ nginx log-directory run-directory server-= blocks >> - upstream-blocks file) >> + upstream-blocks server-names-hash-bucket-= size >> + server-names-hash-bucket-max-size file) > > Likewise, at this stage, we should probably use =E2=80=98match-record=E2= =80=99 to avoid > mistakes. I've sent a couple of additional patches now, the first makes the change to using match-record, and the second splits out the configuration file part of the record, and adds a gexp compiler for it. Let me know what you think about the 2nd patch? I don't particularly like the duplication between the two records, as both the and records need the package, log directory and run directory for different reasons. In summary: - nginx: used for the nginx binary in the shepherd service log-directory: created in the activation service run-directory: created in the activation service - nginx: used for the mime.types file log-directory: written in to the config file run-directory: written in to the config file It's important that it's possible to specify the log directory and run directory if you don't use the , and instead use something opaque (like a ). But I dislike the duplication that this is adding. I wonder if there is a better way of supporting the use of a raw configuration file, rather than the record. Possibly by providing an easy way to create a custom nginx-service-type, with a different activation phase? I think that would allow for making the original compile to the configuration file, but then have something like this for a custom config file. (service (nginx-service-type-with-custom-activation nginx-service-type #:run-directory "/var/run/nginx-custom" #:log-directory "/var/run/nginx-custom") (local-file "nginx-custom.conf")) One downside with this approach is that service extensions use the service-type, so modifying it would mean that services that extend nginx wouldn't work with this service type (you'd have to have the original as well, or modify the service with the extension). In the 2nd patch, I put in some (bad) handling of the extension case, as with an opaque config file, you can't do anything. Previously, the configuration was changed, but then this is later ignored, as the file takes precedence. Thanks for reviewing, Chris --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlos96xfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9XdWFg//RDFnwBWXyGPvwIKAeVxFcJ2c3xsuZHbVHwe4v0L7S6CTaERwSsm7gbQX TnmFj4wfQTS7KD45xv9RYBEaUUJ+KS0cuK0uabrznj94BQHaV+BtLnYFiLhHnQO2 l57LrvyTOBFlK0pK/SOZrIza0XRSyou5GjdMJK7hy/Lo56dyPDVDft71ALdaQCYW AZnHOuyTMsYn9iIKY6mTJ+0d4cfAQ/rCjCAGxQiUaDlvF82e24qzK1x1WGOTQNqH M7zXAOVJ98QuKAKrs4StIXQNXvCUwTSnbtP8HIeCpvCidSKC3dNlSrCKIhoKqoam 8mh4NEyQRyDM9euBiF2CtrJJhrAnrxnG8VnDhwf1ulp6qR9669u/A1cc67ovI/ve 7pEW3o2UbdTjBVnjxcm5hx2loIVPm57hLDCmFYfJwsO5Gbm1baOpI6Ia6/rxRXzD FN7/tBfm+GY/uU/IRbvcJY6iBQMha0/oB/IWW+GD2fqcmvVO22baxmQmqT3Le/lE rZohan3kEkb4TaBejl25MSbc21eok2cxLNhCN9I79AwDfmo7vgYnM+jm/U5pZspT CwDi6tOCstnaiUMVkPuoBbcHTgCVuXa4mr6Wky7KqLsyf2mnhhkGtT14zVQ3XLNX 6MB83QK6/OnlmQsRHoAvDmegrlWehwkLHepdZmXG5gfzDQGSiL0= =Rfzx -----END PGP SIGNATURE----- --=-=-=-- From unknown Mon Aug 18 09:06:47 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#29466] [PATCH 1/2] services: web: Switch nginx related functions to use match-record. Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 11 Dec 2017 16:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29466 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Christopher Baines Cc: 29466@debbugs.gnu.org Received: via spool by 29466-submit@debbugs.gnu.org id=B29466.151300834511640 (code B ref 29466); Mon, 11 Dec 2017 16:06:02 +0000 Received: (at 29466) by debbugs.gnu.org; 11 Dec 2017 16:05:45 +0000 Received: from localhost ([127.0.0.1]:57061 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOQaP-00031g-E4 for submit@debbugs.gnu.org; Mon, 11 Dec 2017 11:05:45 -0500 Received: from hera.aquilenet.fr ([141.255.128.1]:39779) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOQaN-00031V-Ao for 29466@debbugs.gnu.org; Mon, 11 Dec 2017 11:05:43 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 20629FD5F; Mon, 11 Dec 2017 17:05:46 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ROEl3omytr1U; Mon, 11 Dec 2017 17:05:45 +0100 (CET) Received: from ribbon (unknown [193.50.110.104]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 63A67FC49; Mon, 11 Dec 2017 17:05:45 +0100 (CET) From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <87zi77lssn.fsf@gnu.org> <20171210084421.26404-1-mail@cbaines.net> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 21 Frimaire an 226 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Mon, 11 Dec 2017 17:05:41 +0100 In-Reply-To: <20171210084421.26404-1-mail@cbaines.net> (Christopher Baines's message of "Sun, 10 Dec 2017 08:44:20 +0000") Message-ID: <87po7lxnai.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.0 (+) 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: 1.0 (+) Christopher Baines skribis: > As this is less prone to mistakes than match. > > * gnu/services/web.scm (default-nginx-config, nginx-activation, > nginx-shepherd-service): Switch from using match-lambda to match-record. Awesome. LGTM! Ludo=E2=80=99. PS: I=E2=80=99d rather let Cl=C3=A9ment or some other nginx-savvy person co= mment on the second patch. From unknown Mon Aug 18 09:06:47 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Christopher Baines Subject: bug#29466: closed (Re: [bug#29466] [PATCH 1/2] services: web: Switch nginx related functions to use match-record.) Message-ID: References: <87wp1t568t.fsf@cbaines.net> <20171127082338.18504-1-mail@cbaines.net> X-Gnu-PR-Message: they-closed 29466 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 29466@debbugs.gnu.org Date: Mon, 11 Dec 2017 21:02:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1513026123-23562-1" This is a multi-part message in MIME format... ------------=_1513026123-23562-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #29466: [PATCH] services: web: Add support for configuring the nginx server= names hash. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 29466@debbugs.gnu.org. --=20 29466: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D29466 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1513026123-23562-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 29466-done) by debbugs.gnu.org; 11 Dec 2017 21:01:26 +0000 Received: from localhost ([127.0.0.1]:57300 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOVCY-00066o-Jj for submit@debbugs.gnu.org; Mon, 11 Dec 2017 16:01:26 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:59428 helo=mira.cbaines.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOVCX-00066d-4V for 29466-done@debbugs.gnu.org; Mon, 11 Dec 2017 16:01:25 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id A5DF113E8C1; Mon, 11 Dec 2017 21:01:23 +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 616E413E8C0; Mon, 11 Dec 2017 21:01:23 +0000 (GMT) Received: from giedi (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 456092d8; Mon, 11 Dec 2017 21:01:23 +0000 (UTC) References: <87zi77lssn.fsf@gnu.org> <20171210084421.26404-1-mail@cbaines.net> <87po7lxnai.fsf@gnu.org> User-agent: mu4e 0.9.18; emacs 25.3.1 From: Christopher Baines To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#29466] [PATCH 1/2] services: web: Switch nginx related functions to use match-record. In-reply-to: <87po7lxnai.fsf@gnu.org> Date: Mon, 11 Dec 2017 21:01:22 +0000 Message-ID: <87wp1t568t.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: 29466-done Cc: 29466-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 Ludovic Court=C3=A8s writes: > Christopher Baines skribis: > >> As this is less prone to mistakes than match. >> >> * gnu/services/web.scm (default-nginx-config, nginx-activation, >> nginx-shepherd-service): Switch from using match-lambda to match-recor= d. > > Awesome. LGTM! Great, I've pushed this and the previous patch. > PS: I=E2=80=99d rather let Cl=C3=A9ment or some other nginx-savvy person = comment on > the second patch. Yeah, that's fine :) I'll close this bug anyway, as the remaining patch I sent is not anywhere near ready yet. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlou8iJfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9Xe/VBAAoM09wG7f/A4o2ApYeUjsEW/zcBJGX9AoDxmAidsIQ0tdmfQtUbuZkedS zIAeFZZEWR98PNtgs2nZm7ir2Otkk4p+iw1m6QL2cKANELuVnQMdJ3b0634CxzYz ld9IUDf/QBMVTruSvAfXfDOZz6Ug8rmeweggd3PkJIebo1pJ8N1ctRY+MqVfG7r2 BQBTKv2VEUs9InLQKY5fmeYvErYaXsBotsKdD1M1+kKMM8CFWZ2Y7pTvc3HnzGRa uHDvWMGGIwLLPJgRmESHHYci6WEKjsehLIzT7PopjRX3IJpmjXf8vhFjrMw7JJJ7 tfGHu777Nrif7k15ogKVcy+vR70o323LXM3gFV1sxTG/qWmWy9g0ktTHT/alNs8j pM7IdH4CyaZjKugYXWWs8sokAL63hQwkFMVdY2/anSNilzJQ6SrXasuphfjAHiht cW4spFjlIwlvEHDB60BCQ1hO4mrBQ2BfKWHKTZ278ZopsFI16P1H2HChnWtdBaFV aDOIFAC5WsDESZ7iyGuSfc1g21hn1BJVawRZm6qkM+VfNufuSM+qygoESYXIQ3Xt duN51Mti81fxmWZ669cwVIEH9EEDpY42jMwY07hLg5Ep0t030jARnFEqGKJI+AMg LQ16+tN876Bo42c6HLKj1Xrv79drM4+uDbdDVrwIE1f1nmfcONQ= =E2Ww -----END PGP SIGNATURE----- --=-=-=-- ------------=_1513026123-23562-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 27 Nov 2017 08:24:02 +0000 Received: from localhost ([127.0.0.1]:59996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJEhu-0000mm-B6 for submit@debbugs.gnu.org; Mon, 27 Nov 2017 03:24:02 -0500 Received: from eggs.gnu.org ([208.118.235.92]:42046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJEhs-0000mH-4G for submit@debbugs.gnu.org; Mon, 27 Nov 2017 03:24:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJEhh-00038k-2F for submit@debbugs.gnu.org; Mon, 27 Nov 2017 03:23:54 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42395) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eJEhg-00038g-W0 for submit@debbugs.gnu.org; Mon, 27 Nov 2017 03:23:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJEhe-0005jR-1w for guix-patches@gnu.org; Mon, 27 Nov 2017 03:23:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJEhZ-00036r-2i for guix-patches@gnu.org; Mon, 27 Nov 2017 03:23:46 -0500 Received: from li622-129.members.linode.com ([212.71.249.129]:52552 helo=mira.cbaines.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJEhY-00036R-QX for guix-patches@gnu.org; Mon, 27 Nov 2017 03:23:41 -0500 Received: by mira.cbaines.net (Postfix, from userid 113) id D769913E81A; Mon, 27 Nov 2017 08:23:38 +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 9D96913E819 for ; Mon, 27 Nov 2017 08:23:38 +0000 (GMT) Received: from localhost.localdomain (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 19b0b87f for ; Mon, 27 Nov 2017 08:23:38 +0000 (UTC) From: Christopher Baines To: guix-patches@gnu.org Subject: [PATCH] services: web: Add support for configuring the nginx server names hash. Date: Mon, 27 Nov 2017 08:23:38 +0000 Message-Id: <20171127082338.18504-1-mail@cbaines.net> X-Mailer: git-send-email 2.14.2 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 (----) The nginx service can fail to start if the server names hash bucket size is too small, which can happen on some systems, and when using QEMU, depending on the CPU. * gnu/services/web.scm (): Add server-names-hash-bucket-size and server-names-hash-bucket-max-size. (default-nginx-config): Add support for the new hash bucket size parameters. (nginx-service, nginx-activation): Pass the new hash bucket size parameters through to the default-nginx-config procedure. * doc/guix.texi (Web Services): Document the new hash bucket size parameters. --- doc/guix.texi | 7 +++++++ gnu/services/web.scm | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 2a6825682..d0a00bdcb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14874,6 +14874,13 @@ This can be useful if you have an existing configuration file, or it's not possible to do what is required through the other parts of the nginx-configuration record. +@item @code{server-names-hash-bucket-size} (default: @code{#f}) +Bucket size for the server names hash tables, defaults to @code{#f} to +use the size of the processors cache line. + +@item @code{server-names-hash-bucket-max-size} (default: @code{#f}) +Maximum bucket size for the server names hash tables. + @end table @end deffn diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 9d713003c..b9acee762 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -38,6 +38,8 @@ nginx-configuration-run-directory nginx-configuration-server-blocks nginx-configuration-upstream-blocks + nginx-configuration-server-names-hash-bucket-size + nginx-configuration-server-names-hash-bucket-max-size nginx-configuration-file @@ -141,6 +143,10 @@ (default '())) ;list of (upstream-blocks nginx-configuration-upstream-blocks (default '())) ;list of + (server-names-hash-bucket-size nginx-configuration-server-names-hash-bucket-size + (default #f)) + (server-names-hash-bucket-max-size nginx-configuration-server-names-hash-bucket-max-size + (default #f)) (file nginx-configuration-file ;#f | string | file-like (default #f))) @@ -235,7 +241,9 @@ of index files." (cons head out))) (fold-right flatten1 '() lst)) -(define (default-nginx-config nginx log-directory run-directory server-list upstream-list) +(define (default-nginx-config nginx log-directory run-directory server-list + upstream-list server-names-hash-bucket-size + server-names-hash-bucket-max-size) (apply mixed-text-file "nginx.conf" (flatten "user nginx nginx;\n" @@ -249,6 +257,18 @@ of index files." " scgi_temp_path " run-directory "/scgi_temp;\n" " access_log " log-directory "/access.log;\n" " include " nginx "/share/nginx/conf/mime.types;\n" + (if server-names-hash-bucket-size + (string-append + " server_names_hash_bucket_size " + (number->string server-names-hash-bucket-size) + ";\n") + "") + (if server-names-hash-bucket-max-size + (string-append + " server_names_hash_bucket_max_size " + (number->string server-names-hash-bucket-max-size) + ";\n") + "") "\n" (map emit-nginx-upstream-config upstream-list) (map emit-nginx-server-config server-list) @@ -268,7 +288,8 @@ of index files." (define nginx-activation (match-lambda (($ nginx log-directory run-directory server-blocks - upstream-blocks file) + upstream-blocks server-names-hash-bucket-size + server-names-hash-bucket-max-size file) #~(begin (use-modules (guix build utils)) @@ -289,13 +310,16 @@ of index files." (system* (string-append #$nginx "/sbin/nginx") "-c" #$(or file (default-nginx-config nginx log-directory - run-directory server-blocks upstream-blocks)) + run-directory server-blocks upstream-blocks + server-names-hash-bucket-size + server-names-hash-bucket-max-size)) "-t"))))) (define nginx-shepherd-service (match-lambda (($ nginx log-directory run-directory server-blocks - upstream-blocks file) + upstream-blocks server-names-hash-bucket-size + server-names-hash-bucket-max-size file) (let* ((nginx-binary (file-append nginx "/sbin/nginx")) (nginx-action (lambda args @@ -304,7 +328,9 @@ of index files." (system* #$nginx-binary "-c" #$(or file (default-nginx-config nginx log-directory - run-directory server-blocks upstream-blocks)) + run-directory server-blocks upstream-blocks + server-names-hash-bucket-size + server-names-hash-bucket-max-size)) #$@args)))))) ;; TODO: Add 'reload' action. -- 2.14.2 ------------=_1513026123-23562-1--