From 8805c7eab1d375846dd648065979d8d1a062f176 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Tue, 12 Apr 2022 11:30:58 +0300 Subject: home: shepherd: Prevent launching the second instance. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes . * 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 --- gnu/home/services/shepherd.scm | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'gnu/home') 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 @@ (define (launch-shepherd-gexp config) (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) -- cgit v1.2.3