func()

in internal/service/service_windows.go [98:137]


func (ws *winService) Execute(_ []string, requestChan <-chan svc.ChangeRequest, statusChan chan<- svc.Status) (bool, uint32) {
	statusChan <- svc.Status{State: svc.StartPending, Accepts: 0}

outer:
	for {
		select {
		// Handle application requested state transitions.
		case state := <-ws.stateTransitionChan:
			if state == StateRunning {
				galog.Info("Transitioning windows service manager to running")
				statusChan <- svc.Status{
					State:   svc.Running,
					Accepts: svc.AcceptStop | svc.AcceptShutdown | svc.Accepted(windows.SERVICE_ACCEPT_PARAMCHANGE),
				}
			} else if state == StateStopped {
				galog.Info("Transitioning windows service manager to stopped")
				statusChan <- svc.Status{State: svc.StopPending}
				serviceManagerSignal <- true
				break outer
			}
			// Handle windows service manager's transitions.
		case request := <-requestChan:
			switch request.Cmd {
			case svc.Cmd(windows.SERVICE_CONTROL_PARAMCHANGE):
				statusChan <- request.CurrentStatus
			case svc.Interrogate:
				statusChan <- request.CurrentStatus
			case svc.Stop, svc.Shutdown:
				galog.Infof("Stopping %q windows service", nativeServiceName)
				statusChan <- svc.Status{State: svc.StopPending}
				serviceManagerSignal <- true
				break outer
			default:
				galog.Warnf("Unknown request command from windows service manager: %d", request.Cmd)
			}
		}
	}

	return false, 0
}