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 ms0.migadu.com with LMTPS id mGHMEc1GVWL+GQAAgWs5BA (envelope-from ) for ; Tue, 12 Apr 2022 11:30:53 +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 KAvCCs1GVWLtBgAAG6o9tA (envelope-from ) for ; Tue, 12 Apr 2022 11:30:53 +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 8FBF32CB91 for ; Tue, 12 Apr 2022 11:30:52 +0200 (CEST) Received: from localhost ([::1]:54892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1neCrL-00062B-JM for larch@yhetil.org; Tue, 12 Apr 2022 05:30:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1neCpa-00061l-Oe for bug-guix@gnu.org; Tue, 12 Apr 2022 05:29:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1neCpa-0005uR-EI for bug-guix@gnu.org; Tue, 12 Apr 2022 05:29:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1neCpa-0006FG-AZ for bug-guix@gnu.org; Tue, 12 Apr 2022 05:29: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: Tue, 12 Apr 2022 09:29: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.164975568823904 (code B ref 54545); Tue, 12 Apr 2022 09:29:02 +0000 Received: (at 54545) by debbugs.gnu.org; 12 Apr 2022 09:28:08 +0000 Received: from localhost ([127.0.0.1]:47536 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1neCoh-0006DS-SW for submit@debbugs.gnu.org; Tue, 12 Apr 2022 05:28:08 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:56493) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1neCog-0006Cu-0F for 54545@debbugs.gnu.org; Tue, 12 Apr 2022 05:28:06 -0400 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id 59E6220007; Tue, 12 Apr 2022 09:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1649755679; 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=4f2Xyko9X2L2LAw73TW/hVvuyNYpRxawrB3FciDXQGE=; b=NxU3XI4LZeuS7kwyQBIO/QdS/NpkNdpmr35iFs0E85Qx1eORDebMD3Gyp0cm6qov4adAHx P6hmnn1BK2ekvaqOQ8FNWvKYwEsFCM6sQ821dt9Sws9nrBC4DVzUQg2zTnP2keQ4HgCU+Y yqafgY0M9vpLzVd4LcMTLCtc2EagDVf/bYItWiYv7V9BHNlF9F7exmwesB+7zej6Ya4IA4 PzDuvMe79qLWRjQVPM6vGF9dC8ctdmDBNJ/kmnT5q88yF2r+5cOmKidA155xktxJX0DSDg uu+8inzCw89lEEGi1AR/Dgt3b5F/bb/Ej8Jk5RB+Pe92I7LUOCGdUb9wcdmviw== From: Andrew Tropin In-Reply-To: <871qyctxhk.fsf@gnu.org> References: <87a6dfbfdl.fsf@inria.fr> <87sfqt2vwd.fsf@trop.in> <871qyctxhk.fsf@gnu.org> Date: Tue, 12 Apr 2022 12:27:55 +0300 Message-ID: <871qy2irc4.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=1649755852; 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=4f2Xyko9X2L2LAw73TW/hVvuyNYpRxawrB3FciDXQGE=; b=AZrYO57nTgkeuzZDEYbTIk2CX8R/2woRRnN85W7CvWbqfCGPprxng07fI+ET2WbdX1c5EU dxHbJgXZaB6IO2IyAMNBhx/ylr+oRiAgjuBY8y5tcq3wUmLnFFdN/0H3KllsQxbrVBxYlA VxmL04PwoAK9U6Upsr+p3d6cdE5y7GbPDj8IFecJJj7LtLkP+1fL6tqEUqzrWstXftgJwI RUZprJvw9vx5ENi7vLKrLHH2hIXPfqWyartbml/9saJ4L9RF/D/dP7/u5gwCQUUNLqUgkc KqJKet1NNuVfIrpTKGPmxU/sm+x6qyqmmiMnPrgKaHjHV1UOjQt7oB/2xJ4o3w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649755852; a=rsa-sha256; cv=none; b=WS+j0x/F7TzxIYOzXti9/3xDWMGxIQTU6OkTRxjf0joHVVVqjK4SD106Z73iU3jWRJpz85 Wby+vfRVyVj55GQuAwCcbYqtTqpRCwmMGNQBfZMJ2xZCeVBkZ/feiTxheTl1jXrRQvm5AU 5cgr3hlpgtoPCO7k9QUqIEBAhYXvDssS9P3FIFAa68i9HHtL0S5arRA1HOTNs2DtNGL6yc MUWjv6z6Tqm5ZPj1BdoMPYvD6h0aWgPuBPTtjst29sEOIF25b6n1jlmeuEZNjpa/SsqHPu XF9PAz4WOn+oO5NdwdBt1ANkuX64cRRdosm3NMMS7KtjrxtQpVqyLf3jkUeCGA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=NxU3XI4L; 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.66 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=NxU3XI4L; 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: 8FBF32CB91 X-Spam-Score: -0.66 X-Migadu-Scanner: scn0.migadu.com X-TUID: CU6IRd4jXEZP --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2022-04-04 22:16, Ludovic Court=C3=A8s wrote: > Hi, > > Andrew Tropin skribis: > >> Activation script tries to load latest shepherd configuration with `herd >> load root ./path/to/config.scm` and it starts a shepherd process. Login >> shell starts the shepherd process as well. 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. > >> I can think on the proper solution and make a patch with a fix later >> this week or beginning of the next week. > > Awesome, thanks for taking a look! > > Ludo=E2=80=99. 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-home-shepherd-Prevent-launching-the-second-instance.patch Content-Transfer-Encoding: quoted-printable From=20d2578f8924217451ca20f0b61fd6f9b9d31c930d 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 instance. * gnu/home/services/shepherd.scm: Prevent launching the second instance. =2D-- gnu/home/services/shepherd.scm | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/gnu/home/services/shepherd.scm b/gnu/home/services/shepherd.scm index 012585fea4..df6bbb30e6 100644 =2D-- a/gnu/home/services/shepherd.scm +++ b/gnu/home/services/shepherd.scm @@ -93,17 +93,21 @@ (define (launch-shepherd-gexp config) (services (home-shepherd-configuration-services config))) (if (home-shepherd-configuration-auto-start? config) (with-imported-modules '((guix build utils)) =2D #~(let ((log-dir (or (getenv "XDG_LOG_HOME") =2D (format #f "~a/.local/var/log" (getenv "H= OME"))))) =2D ((@ (guix build utils) mkdir-p) log-dir) =2D (system* =2D #$(file-append shepherd "/bin/shepherd") =2D "--logfile" =2D (string-append =2D log-dir =2D "/shepherd.log") =2D "--config" =2D #$(home-shepherd-configuration-file services shepherd)))) + #~(unless (file-exists? + (string-append + (or (getenv "XDG_RUNTIME_DIR") + (format #f "/run/user/~a" (getuid))) + "/shepherd/socket")) + (let ((log-dir (or (getenv "XDG_LOG_HOME") + (format #f "~a/.local/var/log" + (getenv "HOME"))))) + ((@ (guix build utils) mkdir-p) log-dir) + (system* + #$(file-append shepherd "/bin/shepherd") + "--logfile" + (string-append log-dir "/shepherd.log") + "--config" + #$(home-shepherd-configuration-file services shepherd))))) #~""))) =20 (define (reload-configuration-gexp config) =2D-=20 2.35.1 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-home-shepherd-Use-run-on-change-to-reload-shepherd-c.patch Content-Transfer-Encoding: quoted-printable From=2056d16b4cd511f6837329b888dade0c6d6da4d89d 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 necessary to use run-on-change service. =2D-- gnu/home/services/shepherd.scm | 40 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/gnu/home/services/shepherd.scm b/gnu/home/services/shepherd.scm index df6bbb30e6..9a99fed2b5 100644 =2D-- a/gnu/home/services/shepherd.scm +++ b/gnu/home/services/shepherd.scm @@ -105,27 +105,30 @@ (define (launch-shepherd-gexp config) (system* #$(file-append shepherd "/bin/shepherd") "--logfile" =2D (string-append log-dir "/shepherd.log") =2D "--config" =2D #$(home-shepherd-configuration-file services shepherd))= ))) + (string-append log-dir "/shepherd.log"))))) #~""))) =20 (define (reload-configuration-gexp config) (let* ((shepherd (home-shepherd-configuration-shepherd config)) (services (home-shepherd-configuration-services config))) =2D #~(system* =2D #$(file-append shepherd "/bin/herd") =2D "load" "root" =2D #$(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 =2D(define (ensure-shepherd-gexp config) =2D #~(if (file-exists? =2D (string-append =2D (or (getenv "XDG_RUNTIME_DIR") =2D (format #f "/run/user/~a" (getuid))) =2D "/shepherd/socket")) =2D #$(reload-configuration-gexp config) =2D #$(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 config)= ))) =20 (define-public home-shepherd-service-type (service-type (name 'home-shepherd) @@ -134,8 +137,11 @@ (define-public home-shepherd-service-type home-run-on-first-login-service-type launch-shepherd-gexp) (service-extension =2D home-activation-service-type =2D ensure-shepherd-gexp) + home-xdg-configuration-files-service-type + add-shepherd-configuration) + (service-extension + home-run-on-change-service-type + home-shepherd-run-on-change) (service-extension home-profile-service-type (lambda (config) =2D-=20 2.35.1 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0003-home-run-on-first-login-Add-a-startup-message-to-the.patch Content-Transfer-Encoding: quoted-printable From=20e80e9fae6f6bcd478fa904aad8eb426da3f42f10 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 clear when it begins. =2D-- 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 =2D-- 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")) =20 (let* ((xdg-runtime-dir (or (getenv "XDG_RUNTIME_DIR") (format #f "/run/user/~a" (getuid)))) =2D-=20 2.35.1 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =2D-=20 Best regards, Andrew Tropin --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmJVRhsPHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6w80UQAIfYq0VN7pjUn3N/auRzgWNSFPW08MKUz6cI QmAa2Xo8JLH4Vdq6uHuiJreA107bevnbpTMZiGGKh1Tg9/mmVjTYg8HxZLFcAFhv 2MxZVBxcd9P3vDUreYx+NF6OatlLCFXvEw+evtbn6dLSsuUE/OsPq8Bcx1x92tcu WbF5PZjvTe8Uc8p3Lb/fX+Q6Y76nQJseWZZkEJtstaqwHWSE4QC5Q5BoWlq5UTOI mY+W8Aqt0aqfsszTV0ZX7QtnJmzVHTnD7+O9A45BFtZGz1oyIFFs8v41nTQbdk9U j5jRbNGF7rezdp7lM1ffr1bGwcjCHPz2KYI7oaFDtt7lq+W8eg9KA0P7dJtkoNuL FMoOAXwmmXcKebdSTbqXnjqZKW8vx+HlfTgzBVEsryjZP0bOutXWQQrobi2ipvmE 2a7GJveJZH//IO/9VX6t0B4yA3F+j3IGcn/pCrZ4n7YxljXbydZ/x0oyb4dUrH0Y q0yG7/zFj1QstmQFKYQcURTxzQH/7HWziyzp8GJVJRfb5esTkeD5IAkfW6qYZySC Nc+JVZ6EwI3ax4Nf6yaedZsWlMgfeeXIHv6OhnJf8IP36t7P6Fbw95J6B6ijWwBA RJ+VhfnqmbwliL/MfqEk8ig35lm69iU0r5XTuGiH7uMvqMJVVrbGHvxuVjXnD4nQ wk6dXnIn =SCWs -----END PGP SIGNATURE----- --==-=-=--