Fix error when storagenode-updater service is stopped (#3440)

This commit is contained in:
Kaloyan Raev 2019-11-04 11:22:08 +02:00 committed by GitHub
parent 857c7f3cd7
commit 84fea5820f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

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

View File

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