diff --git a/cmd/storagenode-updater/main.go b/cmd/storagenode-updater/main.go index 1d742a15f..dca2f30e5 100644 --- a/cmd/storagenode-updater/main.go +++ b/cmd/storagenode-updater/main.go @@ -144,7 +144,7 @@ func cmdRun(cmd *cobra.Command, args []string) (err error) { loop := sync2.NewCycle(runCfg.CheckInterval) err = loop.Run(ctx, loopFunc) } - if err != nil && errs2.IsCanceled(err) { + if err != nil && !errs2.IsCanceled(err) { log.Fatal(err) } return nil diff --git a/cmd/storagenode-updater/windows.go b/cmd/storagenode-updater/windows.go index b6743b055..ac8180b3d 100644 --- a/cmd/storagenode-updater/windows.go +++ b/cmd/storagenode-updater/windows.go @@ -20,6 +20,7 @@ import ( ) func init() { + // Check if session is interactive interactive, err := svc.IsAnInteractiveSession() if err != nil { panic("Failed to determine if session is interactive:" + err.Error()) @@ -28,7 +29,17 @@ func init() { if interactive { return } + + // Check if the 'run' command is invoked + if len(os.Args) < 2 { + return + } + if os.Args[1] != "run" { + return + } + + // Initialize the Windows Service handler err = svc.Run("storagenode-updater", &service{}) if err != nil { panic("Service failed: " + err.Error())