better status check
This commit is contained in:
parent
6b70af2943
commit
f3cc26252c
|
|
@ -644,12 +644,8 @@ async function runApp(dir: string, port: number) {
|
||||||
const survivalThreshold = 5000 // Consider non-HTTP apps running after 5s
|
const survivalThreshold = 5000 // Consider non-HTTP apps running after 5s
|
||||||
const startTime = Date.now()
|
const startTime = Date.now()
|
||||||
|
|
||||||
// Use proc.exited as the authoritative death signal instead of ps(1)
|
|
||||||
let processExited = false
|
|
||||||
proc.exited.then(() => { processExited = true })
|
|
||||||
|
|
||||||
while (app.state === 'starting' && app.proc === proc) {
|
while (app.state === 'starting' && app.proc === proc) {
|
||||||
if (processExited) {
|
if (proc.exitCode !== null) {
|
||||||
info(app, 'Process died during startup')
|
info(app, 'Process died during startup')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -680,10 +676,7 @@ async function runApp(dir: string, port: number) {
|
||||||
|
|
||||||
// If process survived long enough, consider it running (non-HTTP app)
|
// If process survived long enough, consider it running (non-HTTP app)
|
||||||
if (Date.now() - startTime >= survivalThreshold) {
|
if (Date.now() - startTime >= survivalThreshold) {
|
||||||
// One final check — process could have died between loop iterations
|
if (proc.exitCode !== null) {
|
||||||
// Yield to let proc.exited handler run if pending
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 0))
|
|
||||||
if (processExited) {
|
|
||||||
info(app, 'Process died during startup')
|
info(app, 'Process died during startup')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user