代码拉取完成,页面将自动刷新
From c65a42ea5d2e3626adfd5d09864b2b4bdb0f27d5 Mon Sep 17 00:00:00 2001
From: Longjun Luo <luolongjuna@gmail.com>
Date: Mon, 26 Dec 2022 23:53:48 +0800
Subject: [PATCH] systemd: solve the problem of parsing pid of message
When restore the service of Notify, need to parse
the right pid.
Signed-off-by: Longjun Luo <luolongjuna@gmail.com>
---
src/client.go | 2 +-
src/systemd.go | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/client.go b/src/client.go
index 2bf6875..70d5832 100644
--- a/src/client.go
+++ b/src/client.go
@@ -79,7 +79,7 @@ func startClient(path string) {
if ret != 0 {
handleRet("restore", ret)
}
- RestoreMainPid(c.Args().Get(1))
+ RestoreMainPid(c.Args().First())
NotifySytemd()
SystemdReload()
return nil
diff --git a/src/systemd.go b/src/systemd.go
index 65c53bc..cae7c05 100644
--- a/src/systemd.go
+++ b/src/systemd.go
@@ -1,11 +1,18 @@
package main
import (
+ "strings"
"github.com/coreos/go-systemd/daemon"
log "github.com/sirupsen/logrus"
)
-func RestoreMainPid(pid string) {
+func RestoreMainPid(command string) {
+ commands := strings.Split(command, "@")
+ if (len(commands) != 2) {
+ log.Errorf("Invalid command format %s \n", command)
+ return
+ }
+ pid := commands[1]
ifSupport, err := daemon.SdNotify(false, "READY=1\nMAINPID="+pid)
if ifSupport == false || err != nil {
log.Errorf("Unable to notify systemd, support %v err %s \n", ifSupport, err)
--
2.38.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。