mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-17 18:26:36 +00:00
chore: enable more linter (#1557)
This commit is contained in:
@@ -17,31 +17,32 @@ type windowsExporterService struct{}
|
||||
|
||||
var logger *eventlog.Log
|
||||
|
||||
//nolint:nonamedreturns
|
||||
func (s *windowsExporterService) Execute(_ []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) {
|
||||
const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown
|
||||
changes <- svc.Status{State: svc.StartPending}
|
||||
changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted}
|
||||
loop:
|
||||
for {
|
||||
select {
|
||||
case c := <-r:
|
||||
switch c.Cmd {
|
||||
case svc.Interrogate:
|
||||
changes <- c.CurrentStatus
|
||||
case svc.Stop, svc.Shutdown:
|
||||
_ = logger.Info(100, "Service Stop Received")
|
||||
changes <- svc.Status{State: svc.StopPending}
|
||||
break loop
|
||||
default:
|
||||
_ = logger.Error(102, fmt.Sprintf("unexpected control request #%d", c))
|
||||
}
|
||||
|
||||
for c := range r {
|
||||
switch c.Cmd {
|
||||
case svc.Interrogate:
|
||||
changes <- c.CurrentStatus
|
||||
case svc.Stop, svc.Shutdown:
|
||||
_ = logger.Info(100, "Service Stop Received")
|
||||
changes <- svc.Status{State: svc.StopPending}
|
||||
|
||||
return
|
||||
default:
|
||||
_ = logger.Error(102, fmt.Sprintf("unexpected control request #%d", c))
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
var StopCh = make(chan bool)
|
||||
|
||||
//nolint:gochecknoinits
|
||||
func init() {
|
||||
isService, err := svc.IsWindowsService()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user