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>
This commit is contained in:
Andrew Tropin 2022-04-12 11:30:58 +03:00 committed by Ludovic Courtès
parent 6a69e41c17
commit 8805c7eab1
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -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)