cmd/storagenode: simplify windows service loop
Remove some testing code that is not necessary for the service. Change-Id: Idd09d62bf022d6e66943983f98642fc3c9aa72f7
This commit is contained in:
parent
609526f6aa
commit
4a530ccffd
@ -14,7 +14,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
@ -62,26 +61,26 @@ func (m *service) Execute(args []string, r <-chan svc.ChangeRequest, changes cha
|
|||||||
process.Exec(rootCmd)
|
process.Exec(rootCmd)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
defer group.Wait()
|
||||||
|
|
||||||
changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted}
|
changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted}
|
||||||
|
|
||||||
|
cmdloop:
|
||||||
for c := range r {
|
for c := range r {
|
||||||
switch c.Cmd {
|
switch c.Cmd {
|
||||||
case svc.Interrogate:
|
case svc.Interrogate:
|
||||||
zap.L().Info("Interrogate request received.")
|
zap.L().Info("Interrogate request received.")
|
||||||
changes <- c.CurrentStatus
|
changes <- c.CurrentStatus
|
||||||
// Testing deadlock from https://code.google.com/p/winsvc/issues/detail?id=4
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
changes <- c.CurrentStatus
|
|
||||||
case svc.Stop, svc.Shutdown:
|
case svc.Stop, svc.Shutdown:
|
||||||
zap.L().Info("Stop/Shutdown request received.")
|
zap.L().Info("Stop/Shutdown request received.")
|
||||||
changes <- svc.Status{State: svc.StopPending}
|
|
||||||
// Cancel the command's root context to cleanup resources
|
// Cancel the command's root context to cleanup resources
|
||||||
_, cancel := process.Ctx(runCmd)
|
_, cancel := process.Ctx(runCmd)
|
||||||
cancel()
|
cancel()
|
||||||
_ = group.Wait() // process.Exec does not return an error
|
|
||||||
// After returning the Windows Service is stopped and the process terminates
|
changes <- svc.Status{State: svc.StopPending, Accepts: cmdsAccepted}
|
||||||
return false, 0
|
|
||||||
|
break cmdloop
|
||||||
default:
|
default:
|
||||||
zap.L().Info("Unexpected control request.", zap.Uint32("Event Type", c.EventType))
|
zap.L().Info("Unexpected control request.", zap.Uint32("Event Type", c.EventType))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user