From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iEEILmRsVmLcwwAAgWs5BA (envelope-from ) for ; Wed, 13 Apr 2022 08:23:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id MC9XK2RsVmLUVwAA9RJhRA (envelope-from ) for ; Wed, 13 Apr 2022 08:23:32 +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 214063E3DF for ; Wed, 13 Apr 2022 08:23:32 +0200 (CEST) Received: from localhost ([::1]:56378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1neWPa-0007DJ-RL for larch@yhetil.org; Wed, 13 Apr 2022 02:23:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1neWP8-0007D6-IC for bug-guix@gnu.org; Wed, 13 Apr 2022 02:23:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:57459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1neWP8-0006ai-9i for bug-guix@gnu.org; Wed, 13 Apr 2022 02:23:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1neWP8-0000IC-4B for bug-guix@gnu.org; Wed, 13 Apr 2022 02:23:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#54545: [Guix Home] =?UTF-8?Q?=E2=80=98shepherd=E2=80=99?= started twice? Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 13 Apr 2022 06:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54545 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 54545-submit@debbugs.gnu.org id=B54545.16498309591075 (code B ref 54545); Wed, 13 Apr 2022 06:23:02 +0000 Received: (at 54545) by debbugs.gnu.org; 13 Apr 2022 06:22:39 +0000 Received: from localhost ([127.0.0.1]:51356 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1neWOl-0000HG-BB for submit@debbugs.gnu.org; Wed, 13 Apr 2022 02:22:39 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:52301) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1neWOj-0000H2-4Z for 54545@debbugs.gnu.org; Wed, 13 Apr 2022 02:22:38 -0400 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id 064A660005; Wed, 13 Apr 2022 06:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1649830951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nmwJkmbxwtbk80DF7zfb5Our9TdUh/gfZ8WIx94tCtw=; b=GNwjIfsNAhdI+CmXQYrtum1OU79NcYweD/DZYdKFZaSIeynDrt/+Pu8aGPSJBSphxiBdBF oYWiOurUMuxLD520DwjSCCvKeb3WTQmniCv7Pht4QgERA3XjhQ/dc1S8OSM0YnXTL3hnLR jv8ziQao54qkv2Zn6TzaKA7yrHVtGJ3mIz6FHcbbzxkcA9pVcKCI6F5vCckZJ26fOuL6ze 8hR853f0ktmMTwCH8X/XYqTCHkRkkNmy5UrmbBJJ7/zLoCaiHerBwDiJPuvY38KefUd7D/ TQPow3XukE6jEyncGOyXPZN2I6rfC/8LwA/WuhBMn5Nl7Vcyzw2fp2hmKXyz/A== From: Andrew Tropin In-Reply-To: <87czhmcg26.fsf@gnu.org> References: <87a6dfbfdl.fsf@inria.fr> <87sfqt2vwd.fsf@trop.in> <871qyctxhk.fsf@gnu.org> <871qy2irc4.fsf@trop.in> <87czhmcg26.fsf@gnu.org> Date: Wed, 13 Apr 2022 09:22:27 +0300 Message-ID: <87y209jye4.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 54545@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" 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=1649831012; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=nmwJkmbxwtbk80DF7zfb5Our9TdUh/gfZ8WIx94tCtw=; b=QRbh+eLOucid8hW26p0s0LF8kKRDVzsMQWQXfVO+dzhI7drORzi8CufS+yckMG8cqzelsK HfTVS3FgXBAM/ePCUBdu0AxtSHJx8GmxcHqL4IOE2QbDPKHj+JUn4rDrVl2DmDc++kX/Og j3D5PTGfCvFZUFYUtYtUbexg/CoMxt5C9i7esROiB4i4Dhz3VLPnSOn0i0Um2iUNKW8rjg hy8hB285gpYRtVo0HLphTZMYsIHM2Uk8rVdyDUEJphn3H+sSKjiHX1gG1u1I7RRVGMTcLM UuCviuyJfnbsfKqGi2EkczY79bjKGzdMwR1aZ3PQkY94fjOaqwiNZYe00Umw9g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649831012; a=rsa-sha256; cv=none; b=SsPbv7bPwgTSuyVyxIDphxpt0LRxsJZqvZzK/0qL0v7r6OhbP0SU/6gk2tuanClVqX2aVg A9gNJmDkRHpO7XSLHBQ/4TzjsLtCEFlTzOhtMshGalu0+7Q2rh0PY5s+8nR8mtWajbZjV5 61UIbkGrQ8OwLoSNCrcyxGp2AKbJ8Jn7VBQ/VEjdwe3Y996lQ5ZY+OdYPkl1vVcpLY/kpH I7i4QBuysf9oYZ03MlKMbhPygZhZ4iL81HugfpnE01OXGVVIxPv8uL9CBNnrV5D+RYHK4D ig4ISXnd6R+lGw/tfNbwa0DfeY5wTSCXmiIIMJOPU9hNRDuEOgXDfQaCqXv6JQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=GNwjIfsN; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -0.26 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=GNwjIfsN; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 214063E3DF X-Spam-Score: -0.26 X-Migadu-Scanner: scn1.migadu.com X-TUID: FKOL3XC+90Dc --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2022-04-12 20:28, Ludovic Court=C3=A8s wrote: > Hi, > > Andrew Tropin skribis: > >> Prepared a patch series, which fixes the issues and sligthly adjusts the >> way home shepherd reload configuration logic works, now it happens only >> if configuration is changed and also it doesn't try to be smart and >> start a shepherd if it's not started yet. >> >> From d2578f8924217451ca20f0b61fd6f9b9d31c930d Mon Sep 17 00:00:00 2001 >> From: Andrew Tropin >> Date: Tue, 12 Apr 2022 11:30:58 +0300 >> Subject: [PATCH 1/3] home: shepherd: Prevent launching the second instan= ce. >> >> * gnu/home/services/shepherd.scm: Prevent launching the second instance. > > I applied this one with a convention commit log, including a =E2=80=9CFix= es=E2=80=9D > line, which is important for traceability. (Please check the ChangeLog > convention for future patches.) > Read it from time to time, but the information about contribution guidelines is too much spreaded, for example I can't find info about Fixes line even with search, but maybe I just not very attentive. https://guix.gnu.org/en/manual/devel/en/guix.html#Sending-a-Patch-Series-1 https://www.gnu.org/prep/standards/standards.html#Change-Logs >> From 56d16b4cd511f6837329b888dade0c6d6da4d89d Mon Sep 17 00:00:00 2001 >> From: Andrew Tropin >> Date: Tue, 12 Apr 2022 12:19:50 +0300 >> Subject: [PATCH 2/3] home: shepherd: Use run-on-change to reload shepherd >> config. >> >> * gnu/home/services/shepherd.scm: Add shepherd configuration to >> XDG_CONFIG_HOME and use it instead of full path to the store. It's neces= sary >> to use run-on-change service. > > [...] > >> +++ b/gnu/home/services/shepherd.scm >> @@ -105,27 +105,30 @@ (define (launch-shepherd-gexp config) >> (system* >> #$(file-append shepherd "/bin/shepherd") >> "--logfile" >> - (string-append log-dir "/shepherd.log") >> - "--config" >> - #$(home-shepherd-configuration-file services shepherd)= )))) >> + (string-append log-dir "/shepherd.log"))))) >> #~""))) >>=20=20 >> (define (reload-configuration-gexp config) >> (let* ((shepherd (home-shepherd-configuration-shepherd config)) >> (services (home-shepherd-configuration-services config))) >> - #~(system* >> - #$(file-append shepherd "/bin/herd") >> - "load" "root" >> - #$(home-shepherd-configuration-file services shepherd)))) >> + #~(when (file-exists? >> + (string-append >> + (or (getenv "XDG_RUNTIME_DIR") >> + (format #f "/run/user/~a" (getuid))) >> + "/shepherd/socket")) >> + (system* >> + #$(file-append shepherd "/bin/herd") >> + "load" "root" >> + #$(home-shepherd-configuration-file services shepherd))))) >>=20=20 >> -(define (ensure-shepherd-gexp config) >> - #~(if (file-exists? >> - (string-append >> - (or (getenv "XDG_RUNTIME_DIR") >> - (format #f "/run/user/~a" (getuid))) >> - "/shepherd/socket")) >> - #$(reload-configuration-gexp config) >> - #$(launch-shepherd-gexp config))) >> +(define (add-shepherd-configuration config) >> + (let* ((shepherd (home-shepherd-configuration-shepherd config)) >> + (services (home-shepherd-configuration-services config))) >> + `(("shepherd/init.scm" >> + ,(home-shepherd-configuration-file services shepherd))))) >> + >> +(define (home-shepherd-run-on-change config) >> + `(("files/.config/shepherd/init.scm" ,(reload-configuration-gexp conf= ig)))) > > How does this relate to the bug at hand? > > https://issues.guix.gnu.org/54545 > Almost directly. During activation if there is no shepherd process we tried to launch a new one, which was useful back in the days, when I was testing changes frequently, but can be kinda unexpected for user, if they stopped Shepherd for some reason, but during activation it started again automatically. As we discussed earlier: >>> Probably we need to do config reload using on-change service and also >>> not trigger on-change stuff if user isn't logged in. >> Makes sense. it would be nice to reload configuration only if it's changed. To make run-on-change work we need to store a config somewhere in home-environment, to make it possible to compare with previous generation. files/.config/shepherd/init.scm looks like a good match here, in addition to on-change functionality it increases explorability. > As discussed elsewhere, I find it less ambiguous to pass store file > names for configuration files. > I don't know how much value in it, but we can keep those lines: >> - "--config" >> - #$(home-shepherd-configuration-file services shepherd)= )))) >=20 > That can be a drawback in some cases, for daemons that won=E2=80=99t be a= ble > to load a new config from a different location, but shepherd is not in > that category: it can load a config file via =E2=80=98herd load root=E2= =80=99 from any > place. > It is how reload gexp works. > Last, it would be nice if we could use the (guix scripts system > reconfigure) machinery like =E2=80=98guix system reconfigure=E2=80=99 and= =E2=80=98guix deploy=E2=80=99 > to upgrade services. An idea for future work. :-) > >> From e80e9fae6f6bcd478fa904aad8eb426da3f42f10 Mon Sep 17 00:00:00 2001 >> From: Andrew Tropin >> Date: Tue, 12 Apr 2022 12:23:26 +0300 >> Subject: [PATCH 3/3] home: run-on-first-login: Add a startup message to = the >> script. >> >> gnu/home/services.scm: Add a startup message to the script to make it cl= ear >> when it begins. >> --- >> gnu/home/services.scm | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/gnu/home/services.scm b/gnu/home/services.scm >> index 49bd6e3555..e2c51910a8 100644 >> --- a/gnu/home/services.scm >> +++ b/gnu/home/services.scm >> @@ -344,6 +344,7 @@ (define (compute-on-first-login-script _ gexps) >> #~(begin >> (use-modules (guix i18n)) >> #$%initialize-gettext >> + (display (G_ "Starting run-on-first-login script.\n\n")) > > I=E2=80=99m not fond of unconditional low-level logging. In Guix there= =E2=80=99s > relatively little logging and whatever logging there is is controlled by > =E2=80=98-v=E2=80=99; I think we should follow that approach as much as p= ossible. > > Thank you! > > Ludo=E2=80=99. =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmJWbCMPHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6wUlAP/0JcTeqD3pfB0HsKQkHyKkFFUmA4Pl5Wc5bx 5ONYQJgqk2aB4+VAFLu8zZkyc1g3jfLcflLyJI57Y78vU93GjUG790GAy35fPI4o 2FMe822qrI5K0Uxkp03IucPKan4zSeKVWzFyfGE5UnK2Qw/x9TqzWd7FhWq1ZUv4 c3Gk6Bt+6ax/DdJSwCc672FXX/0MqepVaX60MStlbinRUx1WzL9O9/IDJ36A9Ina E4ZEHjZQPJkpwNF+XwH888VuN+ntp0k9SUEA3xoIMDvVlSi0IKIqCFkuY76bmwRB liUJwCbzUgp9RKQ4LEYC31DJFL6UJyXSbfX7jBizWqyp9yhSXEbEg3d8Z6VEMU18 d9IfbVPbqkqjQR9c7pYk1unKVi+OsOyqScopmt7ooGxCvsNMljkksCFKe0nQAOZW KGMoHeBZI87dArbq8aRkNm6NDcZEFQrJ801/yAMuZSSGv/CGxT4+UGLi+khTM7b8 8IQNkwHNfYyW9KXBwRVR7NMt6FFIzsCGPS/T3/sVlkZTGeoxekehp13qLJMA6imm sGTRVjw92p9fUFYf17gpSNslxocPrFD3nnW2oX5r8oQHi9VMdRp/0jMhozOAcWuz MkB8a1pxTVuiCUxnxXYwZ/IcERjLhhlGSuJdt2pORDUiJAkaKAgT1YM6Biromh8H rFSx3eFr =qPbw -----END PGP SIGNATURE----- --=-=-=--