From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id GBxOAPD9Y2ICSQAAbAwnHQ (envelope-from ) for ; Sat, 23 Apr 2022 15:24:00 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id CB0JO+/9Y2JHWwEAG6o9tA (envelope-from ) for ; Sat, 23 Apr 2022 15:23:59 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9AAE39D45 for ; Sat, 23 Apr 2022 15:23:59 +0200 (CEST) Received: from localhost ([::1]:56854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1niFjy-0005qE-Kz for larch@yhetil.org; Sat, 23 Apr 2022 09:23:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1niFeE-0005oN-NT for guix-patches@gnu.org; Sat, 23 Apr 2022 09:18:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33332) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1niFeE-0000h1-Cz for guix-patches@gnu.org; Sat, 23 Apr 2022 09:18:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1niFeE-0006O5-9H for guix-patches@gnu.org; Sat, 23 Apr 2022 09:18:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55080] [PATCH shepherd] service: Gracefully handle non-existing log directories. Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 23 Apr 2022 13:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55080 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55080@debbugs.gnu.org Cc: ludo@gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.165071985324217 (code B ref -1); Sat, 23 Apr 2022 13:18:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Apr 2022 13:17:33 +0000 Received: from localhost ([127.0.0.1]:55462 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1niFdk-0006IO-KP for submit@debbugs.gnu.org; Sat, 23 Apr 2022 09:17:32 -0400 Received: from lists.gnu.org ([209.51.188.17]:53812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1niFdi-0006HN-Rx for submit@debbugs.gnu.org; Sat, 23 Apr 2022 09:17:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1niFdi-0004z1-7x for guix-patches@gnu.org; Sat, 23 Apr 2022 09:17:30 -0400 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]:33336) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1niFdg-0000ea-Bz; Sat, 23 Apr 2022 09:17:29 -0400 Received: by mail-ed1-x542.google.com with SMTP id e30so9964941eda.0; Sat, 23 Apr 2022 06:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:date:subject:to:cc:content-transfer-encoding:message-id :mime-version; bh=LzLJ6HhTZdQMiXZb0LVHUWGq6v6jGE0mOLNURaveW/c=; b=lkcyrcoAZJzIL2LnHAPLzqjnA5jgon2YgEy520ma128SXTs5rMqLrhws30cTOKltv0 EEueM0KcmFdtvQev+KZsGctRpepgetkcOqOHYK/kl8UxUIgdgnl5Ud7+lzkkU7FLL9GK G09HJrNSApWgy+amy1ltJ2AkZ5aM0r8vyazWDUoV/3knwVGB/Cb03jyXGs6EHuAtIRon cZzNtv1uspuDXXAbqBvp9I3hsVagTghaYmI4VGeCawUCetbaWcaU8y4K0P2vdhKGH8eA 2+coEAJBTZmccLeL2Nozod9OU5rY0YsVXVCFUllq2jcnhtwXlbCvAtsBBzU2H3rMO4Gk QxxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:subject:to:cc :content-transfer-encoding:message-id:mime-version; bh=LzLJ6HhTZdQMiXZb0LVHUWGq6v6jGE0mOLNURaveW/c=; b=J/xY9UVLX0DqZ9spplF31hEdegUqyB306Snr+Cq2h2CbAk3RcTmuF9UwK5Cgj/y8r6 sv4iieuos95sHNdtXHVSZMo4pM1GOgRPkpBibuAi60JBivaDOZUYLFy3DV41oRCQW1Tc ee8nmbv/Fk9/m9jmJUQOC3jgnTXx0TqHctGRCZZ1dtbCNMy4/RvjtDou8FRSpGUwyZfF cVFXW9hm/fPX/ezJrv4gK1SrISLr7HpvJENOieGbkcrGUNm9aKFqKlSsdlDXXv4TifC8 0iiZ5c0+BOwWGH0Ttc3cMhrK1cqQMcZppHXC3xClkibIwfmkm+Q3peeg7gTJrbHbxw3/ B+aw== X-Gm-Message-State: AOAM530S97TqeyibpBtiArv7Vw4OdWPnnS/MtnDp280UgClE86lIfEpI 1/wGsU6p9I9eOdhi8PUHZc5yM4PmyEE= X-Google-Smtp-Source: ABdhPJxcOEDoCWbau2L6N86ZiUSRcMdsQj19YI430iE10gDj59WANsnEl8MEJhKseh0dixheUY5ZKQ== X-Received: by 2002:a05:6402:b57:b0:41d:6d9b:7e0d with SMTP id bx23-20020a0564020b5700b0041d6d9b7e0dmr10020860edb.78.1650719844739; Sat, 23 Apr 2022 06:17:24 -0700 (PDT) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id h22-20020a056402281600b004206bd9d0c6sm2287355ede.8.2022.04.23.06.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 06:17:24 -0700 (PDT) From: Liliana Marie Prikler Date: Sat, 23 Apr 2022 15:11:50 +0200 Content-Transfer-Encoding: 7bit Message-ID: <2e5292c2d45e525aa1b8e4c495704104d4121291.camel@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::542; envelope-from=liliana.prikler@gmail.com; helo=mail-ed1-x542.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650720239; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=LzLJ6HhTZdQMiXZb0LVHUWGq6v6jGE0mOLNURaveW/c=; b=H9IvLxAYX4shYPIRp/A//2KkQOkwB3Z4xRKCWHRUomO5oIzYILhDMdmB6PnXYWknj4snhd 9hhXFcUjFS6Z4Cak6ZhwJ3zNVlHi0Imq1U4ULa3AxOOzbparNzEEuSrcuEB1nh9pVUXWNI fJ4KyAc7/gdmUE+Plxhr4qsBD3uxyhP4ZiAjQjxiIKZOU6VwIi//H3v/C31BdPhebB+WPW Vsgu9htz+ZXVbOCvbTELiImsG7uiRO4gcHNjCkgPFOU1GB4u/3eilbYUIichfQMfegMUYE 0h206S0gsSg4Q3R+B/z+BtyW/WHFFRToH43TlQcf5kJ3bcyiPo0sGXhiqMEZfA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650720239; a=rsa-sha256; cv=none; b=c6/Wk7/nXYibHFItwunhUPEOMQnyZAT+0kNK9PCeCXT1uYlnnIkRsjq10Y88FjpfNGTsD3 vfEUxGs3LuzS6gc9CRNk8zbh1TnbCaEORzmDaoCib2XuO8cfs1N/qFyrQwEPvaL5Ph5Nqm x+tBiCs8C4YT4Vwv1c1TaT3hQcgGSbCIPWymUTxc3Kwn3SU9/Jgq1PnTtq4Lr8swJWgsNf eH8kjo1z8mYUhiLSVJyJAyb9NBOONPv+PJPekRyR/L0mn3jE9eaf4TLsh9ACRMAhQiU+Q4 8qbjDIozy+THO1cJ462oVZjdlmM5bbKBbQ8tjsewmxzn9QDAVyA187h2+SkGfw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=lkcyrcoA; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 5.78 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=lkcyrcoA; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 9AAE39D45 X-Spam-Score: 5.78 X-Migadu-Scanner: scn1.migadu.com X-TUID: j1v/OxN5Wsaj * gnu/packages/services.scm (%service-file-logger): New variable, implementing... (service-file-logger): ... the old behaviour of this variable. Catch system errors from %service-file-logger and handle them. --- modules/shepherd/service.scm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm index 013347b..567a08b 100644 --- a/modules/shepherd/service.scm +++ b/modules/shepherd/service.scm @@ -873,9 +873,9 @@ daemon writing FILE is running in a separate PID namespace." (try-again) (apply throw args))))))) -(define (service-file-logger file input) - "Return a thunk meant to run as a fiber that reads from INPUT and logs it to -FILE." +(define (%service-file-logger file input) + "Like 'service-file-logger', but doesn't handle the case in which FILE does +not exist." (let* ((fd (open-fdes file (logior O_CREAT O_WRONLY O_APPEND) #o640)) (output (fdopen fd "al"))) (set-port-encoding! output "UTF-8") @@ -894,6 +894,19 @@ FILE." (format output "~a~a~%" prefix line) (loop)))))))))) +(define (service-file-logger file input) + "Return a thunk meant to run as a fiber that reads from INPUT and logs it to +FILE." + (catch 'system-error + (lambda () + (%service-file-logger file input)) + (lambda args + (if (= ENOENT (system-error-errno args)) + (begin + (mkdir-p (dirname file)) + (%service-file-logger file input)) + (apply throw args))))) + (define (service-builtin-logger command input) "Return a thunk meant to run as a fiber that reads from INPUT and logs to 'log-output-port'." -- 2.35.1