mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-10 17:48:25 +08:00
returning nil for windows pid
This commit is contained in:
parent
884d1938e6
commit
1a49db79ab
2 changed files with 14 additions and 15 deletions
|
@ -36,20 +36,19 @@ func Restart() error {
|
|||
if ncutils.IsWindows() {
|
||||
RestartWindowsDaemon()
|
||||
return nil
|
||||
} else {
|
||||
pid, err := ncutils.ReadPID()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to find pid %w", err)
|
||||
}
|
||||
p, err := os.FindProcess(pid)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to find running process for pid %d -- %w", pid, err)
|
||||
}
|
||||
if err := p.Signal(syscall.SIGHUP); err != nil {
|
||||
return fmt.Errorf("SIGHUP failed -- %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
pid, err := ncutils.ReadPID()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to find pid %w", err)
|
||||
}
|
||||
p, err := os.FindProcess(pid)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to find running process for pid %d -- %w", pid, err)
|
||||
}
|
||||
if err := p.Signal(syscall.SIGHUP); err != nil {
|
||||
return fmt.Errorf("SIGHUP failed -- %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Start - starts system daemon
|
||||
|
|
|
@ -20,7 +20,7 @@ func (*WindowsPIDError) Error() string {
|
|||
// SavePID - saves the pid of running program to disk
|
||||
func SavePID() error {
|
||||
if IsWindows() {
|
||||
return &WindowsPIDError{}
|
||||
return nil
|
||||
}
|
||||
pid := os.Getpid()
|
||||
if err := os.WriteFile(PIDFILE, []byte(fmt.Sprintf("%d", pid)), 0644); err != nil {
|
||||
|
@ -32,7 +32,7 @@ func SavePID() error {
|
|||
// ReadPID - reads a previously saved pid from disk
|
||||
func ReadPID() (int, error) {
|
||||
if IsWindows() {
|
||||
return 0, &WindowsPIDError{}
|
||||
return 0, nil
|
||||
}
|
||||
bytes, err := os.ReadFile(PIDFILE)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue