11 Star 3 Fork 13

src-openEuler/nvwa

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0002-systemd-solve-the-problem-of-parsing-pid-of-message.patch 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
Anatas 提交于 2023-01-03 20:55 . systemd: solve exist problems for systemd
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/nvwa.git
git@gitee.com:src-openeuler/nvwa.git
src-openeuler
nvwa
nvwa
master

搜索帮助