fix: improve gateway PID recovery and port detection (#660)
- Refactor port detection into reusable getListeningPids/killListeningPids - Add ss command fallback when lsof is unavailable - Extract readPidFile for cleaner PID file reading - Remove unnecessary PowerShell candidate from Windows shell detection - Add PID validity check in gateway_state.json fallback (Number.isFinite + > 0) Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -221,7 +221,7 @@ export class GatewayManager {
|
||||
const data = JSON.parse(content)
|
||||
const pid = typeof data.pid === 'number' ? data.pid : parseInt(data.pid, 10) || null
|
||||
const state = data?.gateway_state
|
||||
return pid && (state === 'running' || state === 'starting') ? pid : null
|
||||
return pid && Number.isFinite(pid) && pid > 0 && (state === 'running' || state === 'starting') ? pid : null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user