func()

in cmd/tracing/tracing_windows.go [30:66]


func (a *TracingDaemonService) Execute(args []string, r <-chan svc.ChangeRequest, s chan<- svc.Status) (bool, uint32) {

	// notify service controller status is now StartPending
	s <- svc.Status{State: svc.StartPending}

	// start service
	d := initDaemon(config)
	// Start a routine to monitor all channels/routines initiated are closed
	// This is required for windows as windows daemon wait for process to finish using infinite for loop below
	go d.close()
	runDaemon(d)
	// update service status to Running
	const acceptCmds = svc.AcceptStop | svc.AcceptShutdown
	s <- svc.Status{State: svc.Running, Accepts: acceptCmds}
loop:
	// using an infinite loop to wait for ChangeRequests
	for {
		// block and wait for ChangeRequests
		c := <-r

		// handle ChangeRequest, svc.Pause is not supported
		switch c.Cmd {
		case svc.Interrogate:
			s <- c.CurrentStatus
			// Testing deadlock from https://code.google.com/p/winsvc/issues/detail?id=4
			time.Sleep(100 * time.Millisecond)
			s <- c.CurrentStatus
		case svc.Stop, svc.Shutdown:
			break loop
		default:
			continue loop
		}
	}
	s <- svc.Status{State: svc.StopPending}
	d.stop()
	return false, 0
}