()
| 465 | // --- lifecycle commands ---------------------------------------------------- |
| 466 | |
| 467 | const status = async () => { |
| 468 | if (!existsSync(devDir)) return console.log("no instances"); |
| 469 | const states: InstanceState[] = []; |
| 470 | for (const f of readdirSync(devDir)) { |
| 471 | if (!f.endsWith(".json")) continue; |
| 472 | try { |
| 473 | const parsed: unknown = JSON.parse(readFileSync(join(devDir, f), "utf8")); |
| 474 | if (isInstanceState(parsed)) states.push(parsed); |
| 475 | } catch { |
| 476 | // skip unparseable debris |
| 477 | } |
| 478 | } |
| 479 | if (states.length === 0) return console.log("no instances"); |
| 480 | for (const state of states) { |
| 481 | const live = alive(state.runnerPid); |
| 482 | let label: string; |
| 483 | if (!live) { |
| 484 | label = "DEAD (stale state file)"; |
| 485 | } else if (state.status === "ready") { |
| 486 | const appUrl = state.urls?.app; |
| 487 | if (appUrl && !(await appResponds(appUrl))) { |
| 488 | label = "UNRESPONSIVE (runner alive but app not answering)"; |
| 489 | } else { |
| 490 | label = state.status; |
| 491 | } |
| 492 | } else { |
| 493 | label = state.status; |
| 494 | } |
| 495 | console.log(`${state.target}: ${label} — runner ${state.runnerPid}, since ${state.startedAt}`); |
| 496 | if (live && state.status === "ready") { |
| 497 | if (label === "UNRESPONSIVE (runner alive but app not answering)") { |
| 498 | console.log(` log ${state.logFile}`); |
| 499 | } else { |
| 500 | printInstance(state); |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | }; |
| 505 | |
| 506 | const down = async (targetName: string) => { |
| 507 | const state = readState(targetName); |
no test coverage detected