From c8b8071bee085ecec707662854c0389dc89d828e Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Wed, 20 Apr 2022 10:32:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8A=82=E7=82=B9=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/apps/app_cmd.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/apps/app_cmd.go b/internal/apps/app_cmd.go index 7c67a66..533b255 100644 --- a/internal/apps/app_cmd.go +++ b/internal/apps/app_cmd.go @@ -213,7 +213,16 @@ func (this *AppCmd) runStop() { return } - _, _ = this.sock.Send(&gosock.Command{Code: "stop"}) + // 从systemd中停止 + if runtime.GOOS == "linux" { + systemctl, _ := exec.LookPath("systemctl") + if len(systemctl) > 0 { + _ = exec.Command(systemctl, "stop", teaconst.SystemdServiceName).Run() + } + } + + // 如果仍在运行,则发送停止指令 + _, _ = this.sock.SendTimeout(&gosock.Command{Code: "stop"}, 1*time.Second) fmt.Println(this.product+" stopped ok, pid:", types.String(pid)) }