This commit is contained in:
zyj
2025-07-12 13:35:47 +08:00
commit ef219bef1e
4 changed files with 1112 additions and 0 deletions

1068
dev.md Normal file

File diff suppressed because it is too large Load Diff

5
go.mod Normal file
View File

@@ -0,0 +1,5 @@
module go-process-guardian
go 1.24.3
require golang.org/x/sys v0.34.0 // indirect

2
go.sum Normal file
View File

@@ -0,0 +1,2 @@
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=

37
main.go Normal file
View File

@@ -0,0 +1,37 @@
package main
import (
"flag"
"fmt"
"os"
)
var (
v = flag.Bool("v", false, "查看版本")
start = flag.String("start", "", "启动文件地址")
name = flag.String("name", "", "名称")
restart = flag.String("restart", "", "重启")
stop = flag.String("stop", "", "停止")
)
func main() {
flag.Parse()
// 获取当前进程信息
fmt.Println(os.Getpid())
fmt.Println(os.Getppid())
if *v {
fmt.Println("1.0.1")
}
if *start != "" {
fmt.Println("启动:", *start)
}
if *name != "" {
fmt.Println("名称:", *name)
}
if *restart != "" {
fmt.Println("重启:", *restart)
}
if *stop != "" {
fmt.Println("停止:", *stop)
}
}