From patchwork Mon Apr 3 11:58:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruno Victal X-Patchwork-Id: 11961 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7881D172C8; Mon, 3 Apr 2023 12:59:23 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 7A41816FE1 for ; Mon, 3 Apr 2023 12:59:22 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pjIq5-00060V-Qg; Mon, 03 Apr 2023 07:59:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pjIpy-0005y8-D9 for guix-patches@gnu.org; Mon, 03 Apr 2023 07:59:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pjIpy-0003pa-49 for guix-patches@gnu.org; Mon, 03 Apr 2023 07:59:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pjIpx-0006aR-Me for guix-patches@gnu.org; Mon, 03 Apr 2023 07:59:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62490] [PATCH v2 1/2] services: nginx: Make logging level configurable. References: In-Reply-To: Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 03 Apr 2023 11:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62490 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62490@debbugs.gnu.org Cc: ludo@gnu.org, Bruno Victal , maxim.cournoyer@gmail.com Received: via spool by 62490-submit@debbugs.gnu.org id=B62490.168052310325272 (code B ref 62490); Mon, 03 Apr 2023 11:59:01 +0000 Received: (at 62490) by debbugs.gnu.org; 3 Apr 2023 11:58:23 +0000 Received: from localhost ([127.0.0.1]:43582 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjIpL-0006ZY-42 for submit@debbugs.gnu.org; Mon, 03 Apr 2023 07:58:23 -0400 Received: from smtpm2.myservices.hosting ([185.26.105.233]:50304) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjIpF-0006ZL-Tq for 62490@debbugs.gnu.org; Mon, 03 Apr 2023 07:58:21 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm2.myservices.hosting (Postfix) with ESMTP id C5EC820292; Mon, 3 Apr 2023 13:58:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 70751800A0; Mon, 3 Apr 2023 13:58:13 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6u0t27Oxzo75; Mon, 3 Apr 2023 13:58:10 +0200 (CEST) Received: from guix-nuc.home.arpa (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 1268E8009D; Mon, 3 Apr 2023 13:58:10 +0200 (CEST) From: Bruno Victal Date: Mon, 3 Apr 2023 12:58:02 +0100 Message-Id: <4027e6a1d7a59e11a7f4000b821283a1985f1dcc.1680523067.git.mirai@makinata.eu> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/web.scm ()[log-level]: New field. (assert-valid-log-level): New procedure. (default-nginx-config): Make log-level configurable. * doc/guix.texi (Web Services): Document it. --- doc/guix.texi | 5 +++++ gnu/services/web.scm | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 4f72e2f34a..6a2380aa3e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -29838,6 +29838,11 @@ Web Services @item @code{log-directory} (default: @code{"/var/log/nginx"}) The directory to which NGinx will write log files. +@item @code{log-level} (default: @code{'error}) (type: symbol) +Logging level, which can be any of the following values: @code{'debug}, +@code{'info}, @code{'notice}, @code{'warn}, @code{'error}, @code{'crit}, +@code{'alert}, or @code{'emerg}. + @item @code{run-directory} (default: @code{"/var/run/nginx"}) The directory in which NGinx will create a pid file, and write temporary files. diff --git a/gnu/services/web.scm b/gnu/services/web.scm index d56e893527..4fe9c2d9ab 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -15,6 +15,7 @@ ;;; Copyright © 2020 Oleg Pykhalov ;;; Copyright © 2020, 2021 Alexandru-Sergiu Marton ;;; Copyright © 2022 Simen Endsjø +;;; Copyright © 2023 Bruno Victal ;;; ;;; This file is part of GNU Guix. ;;; @@ -51,6 +52,8 @@ (define-module (gnu services web) #:use-module (gnu packages logging) #:use-module (gnu packages mail) #:use-module (gnu packages rust-apps) + #:autoload (guix i18n) (G_) + #:use-module (guix diagnostics) #:use-module (guix packages) #:use-module (guix records) #:use-module (guix modules) @@ -61,6 +64,7 @@ (define-module (gnu services web) #:use-module ((guix packages) #:select (package-version)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) + #:use-module (srfi srfi-34) #:use-module (ice-9 match) #:use-module (ice-9 format) #:export (httpd-configuration @@ -96,6 +100,7 @@ (define-module (gnu services web) nginx-configuration-nginx nginx-configuration-shepherd-requirement nginx-configuration-log-directory + nginx-configuration-log-level nginx-configuration-run-directory nginx-configuration-server-blocks nginx-configuration-upstream-blocks @@ -562,6 +567,9 @@ (define-record-type* (default '())) ;list of symbols (log-directory nginx-configuration-log-directory ;string (default "/var/log/nginx")) + (log-level nginx-configuration-log-level + (sanitize assert-valid-log-level) + (default 'error)) (run-directory nginx-configuration-run-directory ;string (default "/var/run/nginx")) (server-blocks nginx-configuration-server-blocks @@ -584,6 +592,14 @@ (define-record-type* (file nginx-configuration-file ;#f | string | file-like (default #f))) +(define (assert-valid-log-level level) + "Ensure @var{level} is one of @code{'debug}, @code{'info}, @code{'notice}, +@code{'warn}, @code{'error}, @code{'crit}, @code{'alert}, or @code{'emerg}." + (unless (memq level '(debug info notice warn error crit alert emerg)) + (raise + (formatted-message (G_ "unknown log level '~a'~%") level))) + level) + (define (config-domain-strings names) "Return a string denoting the nginx config representation of NAMES, a list of domain names." @@ -692,6 +708,7 @@ (define (default-nginx-config config) (match-record config (nginx log-directory run-directory + log-level server-blocks upstream-blocks server-names-hash-bucket-size server-names-hash-bucket-max-size @@ -704,7 +721,7 @@ (define (default-nginx-config config) (flatten "user nginx nginx;\n" "pid " run-directory "/pid;\n" - "error_log " log-directory "/error.log info;\n" + "error_log " log-directory "/error.log " (symbol->string log-level) ";\n" (map emit-load-module modules) (map emit-global-directive global-directives) "http {\n" From patchwork Mon Apr 3 11:58:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruno Victal X-Patchwork-Id: 11962 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 38B86172B8; Mon, 3 Apr 2023 13:00:12 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A502716FE1 for ; Mon, 3 Apr 2023 13:00:11 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pjIr0-0006B8-6E; Mon, 03 Apr 2023 08:00:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pjIqw-0006AX-Rj for guix-patches@gnu.org; Mon, 03 Apr 2023 08:00:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pjIqw-00046v-GF for guix-patches@gnu.org; Mon, 03 Apr 2023 08:00:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pjIqw-0006cU-Bk for guix-patches@gnu.org; Mon, 03 Apr 2023 08:00:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62490] [PATCH v2 2/2] services: nginx: Add reopen action. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 03 Apr 2023 12:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62490 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62490@debbugs.gnu.org Cc: ludo@gnu.org, Bruno Victal , maxim.cournoyer@gmail.com Received: via spool by 62490-submit@debbugs.gnu.org id=B62490.168052316825376 (code B ref 62490); Mon, 03 Apr 2023 12:00:02 +0000 Received: (at 62490) by debbugs.gnu.org; 3 Apr 2023 11:59:28 +0000 Received: from localhost ([127.0.0.1]:43586 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjIqN-0006bE-M6 for submit@debbugs.gnu.org; Mon, 03 Apr 2023 07:59:27 -0400 Received: from smtpmciv2.myservices.hosting ([185.26.107.238]:46042) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjIqL-0006b4-G8 for 62490@debbugs.gnu.org; Mon, 03 Apr 2023 07:59:25 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpmciv2.myservices.hosting (Postfix) with ESMTP id 202A120513; Mon, 3 Apr 2023 13:59:23 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id AE0BC800AF; Mon, 3 Apr 2023 13:59:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KSsGCiCdxVLu; Mon, 3 Apr 2023 13:59:23 +0200 (CEST) Received: from guix-nuc.home.arpa (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 23987800AE; Mon, 3 Apr 2023 13:59:23 +0200 (CEST) From: Bruno Victal Date: Mon, 3 Apr 2023 12:58:03 +0100 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: <4027e6a1d7a59e11a7f4000b821283a1985f1dcc.1680523067.git.mirai@makinata.eu> References: <4027e6a1d7a59e11a7f4000b821283a1985f1dcc.1680523067.git.mirai@makinata.eu> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches This is required to allow log file rotations using rottlog, etc. * gnu/services/web.scm (nginx-shepherd-service): Add reopen shepherd action. --- gnu/services/web.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 4fe9c2d9ab..45897d7d6f 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -840,7 +840,11 @@ (define (nginx-shepherd-service config) the same configuration file. It is useful for situations where the same nginx configuration file can point to different things after a reload, such as renewed TLS certificates, or @code{include}d files.") - (procedure (nginx-action "-s" "reload")))))))))) + (procedure (nginx-action "-s" "reload"))) + (shepherd-action + (name 'reopen) + (documentation "Re-open log files.") + (procedure (nginx-action "-s" "reopen")))))))))) (define nginx-service-type (service-type (name 'nginx)