Add error handling for lsof and pgrep commands
This commit is contained in:
parent
1f0c7bd099
commit
df05cbd3aa
|
|
@ -471,6 +471,7 @@ async function killStaleProcesses() {
|
|||
const pids = new Set<number>()
|
||||
|
||||
// Find processes listening on our port range
|
||||
try {
|
||||
const lsof = Bun.spawnSync(['lsof', '-ti', `:${MIN_PORT - 1}-${MAX_PORT}`])
|
||||
const lsofOutput = lsof.stdout.toString().trim()
|
||||
if (lsofOutput) {
|
||||
|
|
@ -478,8 +479,12 @@ async function killStaleProcesses() {
|
|||
if (pid && pid !== process.pid) pids.add(pid)
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// lsof not available (e.g. minimal Linux installs)
|
||||
}
|
||||
|
||||
// Find orphaned "bun run toes" child app processes
|
||||
try {
|
||||
const pgrep = Bun.spawnSync(['pgrep', '-f', 'bun run toes'])
|
||||
const pgrepOutput = pgrep.stdout.toString().trim()
|
||||
if (pgrepOutput) {
|
||||
|
|
@ -487,6 +492,9 @@ async function killStaleProcesses() {
|
|||
if (pid && pid !== process.pid) pids.add(pid)
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// pgrep not available
|
||||
}
|
||||
|
||||
if (pids.size === 0) return
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user