guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/04: home: shepherd: Prevent launching the second instance.


From: guix-commits
Subject: 01/04: home: shepherd: Prevent launching the second instance.
Date: Tue, 12 Apr 2022 17:56:16 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 8805c7eab1d375846dd648065979d8d1a062f176
Author: Andrew Tropin <andrew@trop.in>
AuthorDate: Tue Apr 12 11:30:58 2022 +0300

    home: shepherd: Prevent launching the second instance.
    
    Fixes <https://issues.guix.gnu.org/54545>.
    
    * gnu/home/services/shepherd.scm (launch-shepherd-gexp): Launch shepherd
    if and only if its socket file does not already exist.
    
    Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
 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
--- a/gnu/home/services/shepherd.scm
+++ b/gnu/home/services/shepherd.scm
@@ -93,17 +93,21 @@ as shepherd package."
          (services (home-shepherd-configuration-services config)))
     (if (home-shepherd-configuration-auto-start? config)
         (with-imported-modules '((guix build utils))
-          #~(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))))
+          #~(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)))))
         #~"")))
 
 (define (reload-configuration-gexp config)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]