mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-12 03:10:26 +08:00
重启edge-admin时确保同目录下的edge-api也能重启
This commit is contained in:
@@ -209,7 +209,7 @@ func (this *AppCmd) runStop() {
|
|||||||
fmt.Println(this.product+" stopped ok, pid:", types.String(pid))
|
fmt.Println(this.product+" stopped ok, pid:", types.String(pid))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重启
|
// RunRestart 重启
|
||||||
func (this *AppCmd) RunRestart() {
|
func (this *AppCmd) RunRestart() {
|
||||||
this.runStop()
|
this.runStop()
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -364,6 +366,16 @@ func (this *AdminNode) listenSock() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 停止当前目录下的API节点
|
||||||
|
var apiSock = gosock.NewTmpSock("edge-api")
|
||||||
|
apiReply, err := apiSock.Send(&gosock.Command{Code: "info"})
|
||||||
|
if err == nil {
|
||||||
|
adminExe, _ := os.Executable()
|
||||||
|
if len(adminExe) > 0 && apiReply != nil && strings.HasPrefix(maps.NewMap(apiReply.Params).GetString("path"), filepath.Dir(filepath.Dir(adminExe))) {
|
||||||
|
_, _ = apiSock.Send(&gosock.Command{Code: "stop"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 退出主进程
|
// 退出主进程
|
||||||
events.Notify(events.EventQuit)
|
events.Notify(events.EventQuit)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user