优化node启动

This commit is contained in:
boyce
2024-03-05 17:38:02 +08:00
parent 75ef7302de
commit 2ddc54f5ac
2 changed files with 39 additions and 4 deletions

View File

@@ -0,0 +1,25 @@
package sysprocess
import (
"github.com/shirou/gopsutil/process"
"os"
)
func GetProcessNameByPID(pid int32) (string, error) {
proc, err := process.NewProcess(pid)
if err != nil {
return "", err
}
processName, err := proc.Name()
if err != nil {
return "", err
}
return processName, nil
}
func GetMyProcessName() (string, error) {
return GetProcessNameByPID(int32(os.Getpid()))
}