mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
feat: getPidByPort() supports alpine now (#3483)
Signed-off-by: WindSpiritSR <simon343riley@gmail.com>
This commit is contained in:
parent
3feb6ce84d
commit
c5f25cbc7d
@ -29,7 +29,7 @@ func getPidByPort(port int) (int, error) {
|
|||||||
case "windows":
|
case "windows":
|
||||||
cmd = exec.Command("cmd", "/c", "netstat -ano | findstr :"+strconv.Itoa(port))
|
cmd = exec.Command("cmd", "/c", "netstat -ano | findstr :"+strconv.Itoa(port))
|
||||||
case "darwin", "linux":
|
case "darwin", "linux":
|
||||||
cmd = exec.Command("lsof", "-i", ":"+strconv.Itoa(port))
|
cmd = exec.Command("lsof", "-t", "-i", ":"+strconv.Itoa(port))
|
||||||
default:
|
default:
|
||||||
return 0, fmt.Errorf("unsupported OS: %s", runtime.GOOS)
|
return 0, fmt.Errorf("unsupported OS: %s", runtime.GOOS)
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ func getPidByPort(port int) (int, error) {
|
|||||||
return pid, nil
|
return pid, nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pid, err := strconv.Atoi(fields[1])
|
pid, err := strconv.Atoi(fields[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user