From f297d47e20fbe12acd5f357c4e9e08675e2e0b6f Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Tue, 24 Apr 2018 14:50:01 -0400 Subject: [PATCH] improve daemon shutdown detection --- ytsync.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ytsync.go b/ytsync.go index e56d4f8..781709e 100644 --- a/ytsync.go +++ b/ytsync.go @@ -103,15 +103,15 @@ func (s *Sync) FullCycle() error { shutdownErr := stopDaemonViaSystemd() if shutdownErr != nil { log.Errorf("error shutting down daemon: %v", shutdownErr) - log.Errorf("WALLET HAS NOT BEEN MOVED TO THE WALLET BACKUP DIR", shutdownErr) + log.Errorf("WALLET HAS NOT BEEN MOVED TO THE WALLET BACKUP DIR") } else { // the cli will return long before the daemon effectively stops. we must observe the processes running // before moving the wallet - var waitTimeout time.Duration = 180 + var waitTimeout time.Duration = 60 * 6 processDeathError := waitForDaemonProcess(waitTimeout) if processDeathError != nil { log.Errorf("error shutdown down daemon: %v", processDeathError) - log.Errorf("WALLET HAS NOT BEEN MOVED TO THE WALLET BACKUP DIR", processDeathError) + log.Errorf("WALLET HAS NOT BEEN MOVED TO THE WALLET BACKUP DIR") } else { walletErr := os.Rename(defaultWalletDir, walletBackupDir) if walletErr != nil { @@ -504,7 +504,7 @@ func waitForDaemonProcess(timeout time.Duration) error { //NOTE : syscall.Signal is not available in Windows err = proc.Signal(syscall.Signal(0)) //the process doesn't exist anymore! we're free to go - if err != nil && err == syscall.ESRCH { + if err != nil && (err == syscall.ESRCH || err.Error() == "os: process already finished") { return nil } }