From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJEix-0006Ea-Du for guix-patches@gnu.org; Mon, 27 Nov 2017 03:25:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJEis-0003dx-FP for guix-patches@gnu.org; Mon, 27 Nov 2017 03:25:07 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:51317) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eJEis-0003dr-BH for guix-patches@gnu.org; Mon, 27 Nov 2017 03:25:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eJEis-0000oG-3D for guix-patches@gnu.org; Mon, 27 Nov 2017 03:25:02 -0500 Subject: [bug#29466] [PATCH] services: web: Add support for configuring the nginx server names hash. Resent-Message-ID: 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: 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> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 29466@debbugs.gnu.org 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