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

Method runStop

internal/apps/app_cmd.go:218–240  ·  view source on GitHub ↗

停止

()

Source from the content-addressed store, hash-verified

216
217// 停止
218func (this *AppCmd) runStop() {
219 var pid = this.getPID()
220 if pid == 0 {
221 fmt.Println(this.product + " not started yet")
222 return
223 }
224
225 // 从systemd中停止
226 if runtime.GOOS == "linux" {
227 systemctl, _ := executils.LookPath("systemctl")
228 if len(systemctl) > 0 {
229 go func() {
230 // 有可能会长时间执行,这里不阻塞进程
231 _ = exec.Command(systemctl, "stop", teaconst.SystemdServiceName).Run()
232 }()
233 }
234 }
235
236 // 如果仍在运行,则发送停止指令
237 _, _ = this.sock.SendTimeout(&gosock.Command{Code: "stop"}, 1*time.Second)
238
239 fmt.Println(this.product+" stopped ok, pid:", types.String(pid))
240}
241
242// 重启
243func (this *AppCmd) runRestart() {

Callers 2

RunMethod · 0.95
runRestartMethod · 0.95

Calls 3

getPIDMethod · 0.95
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected