MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / Execute

Method Execute

internal/utils/service_windows.go:97–157  ·  view source on GitHub ↗

同服务管理器的交互

(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status)

Source from the content-addressed store, hash-verified

95
96// 同服务管理器的交互
97func (this *ServiceManager) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) {
98 const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown | svc.AcceptPauseAndContinue
99
100 changes <- svc.Status{
101 State: svc.StartPending,
102 }
103
104 changes <- svc.Status{
105 State: svc.Running,
106 Accepts: cmdsAccepted,
107 }
108
109 // start service
110 this.Log("start")
111 this.cmdStart()
112
113loop:
114 for {
115 select {
116 case c := <-r:
117 switch c.Cmd {
118 case svc.Interrogate:
119 this.Log("cmd: Interrogate")
120 changes <- c.CurrentStatus
121 case svc.Stop, svc.Shutdown:
122 this.Log("cmd: Stop|Shutdown")
123
124 // stop service
125 this.cmdStop()
126
127 break loop
128 case svc.Pause:
129 this.Log("cmd: Pause")
130
131 // stop service
132 this.cmdStop()
133
134 changes <- svc.Status{
135 State: svc.Paused,
136 Accepts: cmdsAccepted,
137 }
138 case svc.Continue:
139 this.Log("cmd: Continue")
140
141 // start service
142 this.cmdStart()
143
144 changes <- svc.Status{
145 State: svc.Running,
146 Accepts: cmdsAccepted,
147 }
148 default:
149 this.LogError(fmt.Sprintf("unexpected control request #%d\r\n", c))
150 }
151 }
152 }
153 changes <- svc.Status{
154 State: svc.StopPending,

Callers

nothing calls this directly

Calls 4

LogMethod · 0.95
cmdStartMethod · 0.95
cmdStopMethod · 0.95
LogErrorMethod · 0.95

Tested by

no test coverage detected