mirror of
https://github.com/kubenetworks/kubevpn.git
synced 2025-12-24 11:51:13 +08:00
feat: write pprof to file when daemon quit (#247)
This commit is contained in:
@@ -85,6 +85,7 @@ const (
|
||||
// pprof port
|
||||
PProfPort = 32345
|
||||
SudoPProfPort = 33345
|
||||
PProfDir = "pprof"
|
||||
|
||||
// startup by KubeVPN
|
||||
EnvStartSudoKubeVPNByKubeVPN = "DEPTH_SIGNED_BY_NAISON"
|
||||
@@ -109,6 +110,7 @@ var (
|
||||
|
||||
DaemonPath string
|
||||
HomePath string
|
||||
PprofPath string
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -129,6 +131,7 @@ func init() {
|
||||
dir, _ := os.UserHomeDir()
|
||||
DaemonPath = filepath.Join(dir, HOME, Daemon)
|
||||
HomePath = filepath.Join(dir, HOME)
|
||||
PprofPath = filepath.Join(dir, HOME, Daemon, PProfDir)
|
||||
}
|
||||
|
||||
var Debug bool
|
||||
|
||||
@@ -29,11 +29,19 @@ const (
|
||||
var config []byte
|
||||
|
||||
func init() {
|
||||
err := os.MkdirAll(DaemonPath, os.ModePerm)
|
||||
err := os.MkdirAll(DaemonPath, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = os.Chmod(DaemonPath, os.ModePerm)
|
||||
err = os.Chmod(DaemonPath, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = os.MkdirAll(PprofPath, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = os.Chmod(PprofPath, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -215,10 +215,10 @@ func (o *SvrOption) detectUnixSocksFile(ctx context.Context) {
|
||||
func writePIDToFile(isSudo bool) error {
|
||||
pidPath := GetPidPath(isSudo)
|
||||
pid := os.Getpid()
|
||||
err := os.WriteFile(pidPath, []byte(strconv.Itoa(pid)), os.ModePerm)
|
||||
err := os.WriteFile(pidPath, []byte(strconv.Itoa(pid)), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Chmod(pidPath, os.ModePerm)
|
||||
err = os.Chmod(pidPath, 0644)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user