mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-20 17:58:02 +02:00
[client] Log duplicate client ui pid (#3915)
This commit is contained in:
parent
616b19c064
commit
f367925496
@ -89,13 +89,13 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for another running process.
|
// Check for another running process.
|
||||||
running, err := process.IsAnotherProcessRunning()
|
pid, running, err := process.IsAnotherProcessRunning()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("error while checking process: %v", err)
|
log.Errorf("error while checking process: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if running {
|
if running {
|
||||||
log.Warn("another process is running")
|
log.Warnf("another process is running with pid %d, exiting", pid)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@ import (
|
|||||||
"github.com/shirou/gopsutil/v3/process"
|
"github.com/shirou/gopsutil/v3/process"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsAnotherProcessRunning() (bool, error) {
|
func IsAnotherProcessRunning() (int32, bool, error) {
|
||||||
processes, err := process.Processes()
|
processes, err := process.Processes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return 0, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pid := os.Getpid()
|
pid := os.Getpid()
|
||||||
@ -29,9 +29,9 @@ func IsAnotherProcessRunning() (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(strings.ToLower(runningProcessPath), processName) && isProcessOwnedByCurrentUser(p) {
|
if strings.Contains(strings.ToLower(runningProcessPath), processName) && isProcessOwnedByCurrentUser(p) {
|
||||||
return true, nil
|
return p.Pid, true, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false, nil
|
return 0, false, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user