diff --git a/src/server/apps.ts b/src/server/apps.ts index 3cb4cef..5a2c38f 100644 --- a/src/server/apps.ts +++ b/src/server/apps.ts @@ -471,21 +471,29 @@ async function killStaleProcesses() { const pids = new Set() // Find processes listening on our port range - const lsof = Bun.spawnSync(['lsof', '-ti', `:${MIN_PORT - 1}-${MAX_PORT}`]) - const lsofOutput = lsof.stdout.toString().trim() - if (lsofOutput) { - for (const pid of lsofOutput.split('\n').map(Number)) { - if (pid && pid !== process.pid) pids.add(pid) + try { + const lsof = Bun.spawnSync(['lsof', '-ti', `:${MIN_PORT - 1}-${MAX_PORT}`]) + const lsofOutput = lsof.stdout.toString().trim() + if (lsofOutput) { + for (const pid of lsofOutput.split('\n').map(Number)) { + 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 - const pgrep = Bun.spawnSync(['pgrep', '-f', 'bun run toes']) - const pgrepOutput = pgrep.stdout.toString().trim() - if (pgrepOutput) { - for (const pid of pgrepOutput.split('\n').map(Number)) { - if (pid && pid !== process.pid) pids.add(pid) + try { + const pgrep = Bun.spawnSync(['pgrep', '-f', 'bun run toes']) + const pgrepOutput = pgrep.stdout.toString().trim() + if (pgrepOutput) { + for (const pid of pgrepOutput.split('\n').map(Number)) { + if (pid && pid !== process.pid) pids.add(pid) + } } + } catch { + // pgrep not available } if (pids.size === 0) return