diff --git a/command/agent/command.go b/command/agent/command.go index d257876e3831..d90429211ae1 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -778,7 +778,7 @@ WAIT: select { case s := <-signalCh: sig = s - case <-winsvc.Shutdown_Channel(): + case <-winsvc.ShutdownChannel(): sig = os.Interrupt case <-c.ShutdownCh: sig = os.Interrupt diff --git a/helper/winsvc/service.go b/helper/winsvc/service.go index 243004741fb1..c8d21f5c7d0a 100644 --- a/helper/winsvc/service.go +++ b/helper/winsvc/service.go @@ -2,6 +2,8 @@ package winsvc var chanGraceExit = make(chan int) -func Shutdown_Channel() <-chan int { +// ShutdownChannel returns a channel that sends a message that a shutdown +// signal has been received for the service. +func ShutdownChannel() <-chan int { return chanGraceExit } diff --git a/helper/winsvc/service_windows.go b/helper/winsvc/service_windows.go index c46ab8a6f4d3..9d208208d557 100644 --- a/helper/winsvc/service_windows.go +++ b/helper/winsvc/service_windows.go @@ -17,11 +17,12 @@ func init() { if interactive { return } - go func() { - _ = wsvc.Run("", serviceWindows{}) - }() + go wsvc.Run("", serviceWindows{})() } +// Execute implements the Windows service Handler type. It will be +// called at the start of the service, and the service will exit +// once Execute completes. func (serviceWindows) Execute(args []string, r <-chan wsvc.ChangeRequest, s chan<- wsvc.Status) (svcSpecificEC bool, exitCode uint32) { const accCommands = wsvc.AcceptStop | wsvc.AcceptShutdown s <- wsvc.Status{State: wsvc.Running, Accepts: accCommands}