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

Method restart

internal/nodes/upgrade_manager.go:242–269  ·  view source on GitHub ↗

重启

()

Source from the content-addressed store, hash-verified

240
241// 重启
242func (this *UpgradeManager) restart() error {
243 // 关闭当前sock,防止无法重启
244 _ = gosock.NewTmpSock(teaconst.ProcessName).Close()
245
246 // 重新启动
247 if DaemonIsOn && DaemonPid == os.Getppid() {
248 utils.Exit() // TODO 试着更优雅重启
249 } else {
250 // quit
251 events.Notify(events.EventQuit)
252
253 // terminated
254 events.Notify(events.EventTerminated)
255
256 // 启动
257 var exe = filepath.Dir(this.exe) + "/" + teaconst.ProcessName
258 var cmd = executils.NewCmd(exe, "start")
259 err := cmd.Start()
260 if err != nil {
261 return err
262 }
263
264 // 退出当前进程
265 time.Sleep(1 * time.Second)
266 os.Exit(0)
267 }
268 return nil
269}

Callers 1

StartMethod · 0.95

Calls 4

ExitFunction · 0.92
NotifyFunction · 0.92
CloseMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected