cleanup
This commit is contained in:
parent
b538626baa
commit
c5672e57bd
|
|
@ -490,14 +490,29 @@ function handleHealthCheckFailure(app: App) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function killStaleProcesses() {
|
async function killStaleProcesses() {
|
||||||
const result = Bun.spawnSync(['lsof', '-ti', `:${MIN_PORT - 1}-${MAX_PORT}`])
|
const pids = new Set<number>()
|
||||||
const output = result.stdout.toString().trim()
|
|
||||||
if (!output) return
|
|
||||||
|
|
||||||
const pids = output.split('\n').map(Number).filter(pid => pid && pid !== process.pid)
|
// Find processes listening on our port range
|
||||||
if (pids.length === 0) return
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hostLog(`Found ${pids.length} stale process(es) on ports ${MIN_PORT - 1}-${MAX_PORT}`)
|
// 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pids.size === 0) return
|
||||||
|
|
||||||
|
hostLog(`Found ${pids.size} stale process(es)`)
|
||||||
for (const pid of pids) {
|
for (const pid of pids) {
|
||||||
try {
|
try {
|
||||||
process.kill(pid, 'SIGKILL')
|
process.kill(pid, 'SIGKILL')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user