From a51fecee9b89529201e31c3ac90f25c47ce3660f Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Thu, 4 Jun 2020 21:43:46 +0300 Subject: [PATCH] Try to update from systemd and old version correctly --- cmd/skywire-visor/commands/root.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/skywire-visor/commands/root.go b/cmd/skywire-visor/commands/root.go index e3a6cd3d9a..60d44d3a13 100644 --- a/cmd/skywire-visor/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -8,6 +8,7 @@ import ( "net/http" _ "net/http/pprof" // nolint:gosec // https://golang.org/doc/diagnostics.html#profiling "os" + "os/exec" "strings" "syscall" "time" @@ -77,12 +78,14 @@ var rootCmd = &cobra.Command{ if delayDuration != 0 && !restartCtx.Systemd() && wd == "/" && path == "/usr/local/bin/skywire-visor" { // from v0.2.3 / parent is run by systemd - // cmd := exec.Command("systemctl", "restart", "skywire-visor") // nolint:gosec - // if err := cmd.Run(); err != nil { - // log.WithError(err).Errorf("Failed to restart skywire-visor service") - // } else { - // log.WithError(err).Infof("Restarted skywire-visor service") - // } + time.Sleep(1 * time.Second) + + cmd := exec.Command("systemctl", "restart", "skywire-visor") // nolint:gosec + if err := cmd.Run(); err != nil { + log.WithError(err).Errorf("Failed to restart skywire-visor service") + } else { + log.WithError(err).Infof("Restarted skywire-visor service") + } if _, err := syscall.Setsid(); err != nil { log.WithError(err).Errorf("Failed to call setsid()")