History

Use runtime-only health checks during install

Rhys Sullivan committed 8 months ago

Commit 4eb800c1 parent e6ecdd12 files · +21 −12Browse files

Unified · Split

2 files
  1. executor/executor.ts +11 −8
  2. executor/install +10 −4
executor/executor.ts+11−8
@@ -344,7 +344,8 @@ Stops background backend/web services started by the install script.`); · 343 unmodified lines
344 344
345async function runDoctor(args: string[]): Promise<number> {345async function runDoctor(args: string[]): Promise<number> {
346 const verbose = args.includes("-v") || args.includes("--verbose");346 const verbose = args.includes("-v") || args.includes("--verbose");
347 const unknownArgs = args.filter((arg) => arg !== "-v" && arg !== "--verbose");347 const runtimeOnly = args.includes("--runtime-only");
348 const unknownArgs = args.filter((arg) => arg !== "-v" && arg !== "--verbose" && arg !== "--runtime-only");
348 if (unknownArgs.length > 0) {349 if (unknownArgs.length > 0) {
349 console.log(`Unknown option: ${unknownArgs[0]}`);350 console.log(`Unknown option: ${unknownArgs[0]}`);
350 return 1;351 return 1;
@@ -358,17 +359,19 @@ async function runDoctor(args: string[]): Promise<number> { · 7 unmodified lines
358 const webRunning = await checkHttp(`http://127.0.0.1:${webPort}/`);359 const webRunning = await checkHttp(`http://127.0.0.1:${webPort}/`);
359 360
360 let bootstrapState: Awaited<ReturnType<typeof checkBootstrapHealth>> | null = null;361 let bootstrapState: Awaited<ReturnType<typeof checkBootstrapHealth>> | null = null;
361 if (backendRunning) {362 if (backendRunning && !runtimeOnly) {
362 bootstrapState = await checkBootstrapHealth(info);363 bootstrapState = await checkBootstrapHealth(info);
363 }364 }
364 365
365 const functionsReady = bootstrapState?.state === "ready";366 const functionsReady = runtimeOnly ? true : bootstrapState?.state === "ready";
366 const healthy = nodeInstalled && webInstalled && backendRunning && webRunning && functionsReady;367 const healthy = nodeInstalled && webInstalled && backendRunning && webRunning && functionsReady;
367 368
368 console.log(`Executor status: ${healthy ? "ready" : "needs attention"}`);369 console.log(`Executor status: ${healthy ? "ready" : "needs attention"}`);
369 console.log(`Dashboard: http://127.0.0.1:${webPort} (${webRunning ? "running" : "not running"})`);370 console.log(`Dashboard: http://127.0.0.1:${webPort} (${webRunning ? "running" : "not running"})`);
370 console.log(`Backend: ${backendRunning ? "running" : "not running"} (${info.convexUrl})`);371 console.log(`Backend: ${backendRunning ? "running" : "not running"} (${info.convexUrl})`);
371 if (!backendRunning) {372 if (runtimeOnly) {
373 console.log("Functions: skipped (runtime-only check)");
374 } else if (!backendRunning) {
372 console.log("Functions: unavailable (backend is not running)");375 console.log("Functions: unavailable (backend is not running)");
373 } else if (bootstrapState?.state === "ready") {376 } else if (bootstrapState?.state === "ready") {
374 console.log("Functions: bootstrapped");377 console.log("Functions: bootstrapped");
@@ -387,13 +390,13 @@ async function runDoctor(args: string[]): Promise<number> { · 12 unmodified lines
387 if (!webRunning) {390 if (!webRunning) {
388 console.log("Next step: run `executor web`");391 console.log("Next step: run `executor web`");
389 }392 }
390 if (backendRunning && bootstrapState?.state === "no_project") {393 if (!runtimeOnly && backendRunning && bootstrapState?.state === "no_project") {
391 console.log("Next step: run from your repo root or set `EXECUTOR_PROJECT_DIR` to a Convex project.");394 console.log("Next step: run from your repo root or set `EXECUTOR_PROJECT_DIR` to a Convex project.");
392 }395 }
393 if (backendRunning && bootstrapState?.state === "missing_functions") {396 if (!runtimeOnly && backendRunning && bootstrapState?.state === "missing_functions") {
394 console.log("Next step: run `executor up` from your project root to bootstrap functions.");397 console.log("Next step: run `executor up` from your project root to bootstrap functions.");
395 }398 }
396 if (backendRunning && bootstrapState?.state === "check_failed") {399 if (!runtimeOnly && backendRunning && bootstrapState?.state === "check_failed") {
397 console.log("Next step: run `executor up` and inspect ~/.executor/runtime/logs/backend.log");400 console.log("Next step: run `executor up` and inspect ~/.executor/runtime/logs/backend.log");
398 }401 }
399 if (!webInstalled || !nodeInstalled) {402 if (!webInstalled || !nodeInstalled) {
@@ -409,7 +412,7 @@ async function runDoctor(args: string[]): Promise<number> { · 9 unmodified lines
409 console.log(` convex site: ${info.convexSiteUrl}`);412 console.log(` convex site: ${info.convexSiteUrl}`);
410 console.log(` node runtime: ${nodeInstalled ? info.nodeBin : "missing"}`);413 console.log(` node runtime: ${nodeInstalled ? info.nodeBin : "missing"}`);
411 console.log(` web bundle: ${webInstalled ? info.webServerEntry : "missing"}`);414 console.log(` web bundle: ${webInstalled ? info.webServerEntry : "missing"}`);
412 console.log(` functions: ${bootstrapState?.state ?? "unavailable"}`);415 console.log(` functions: ${runtimeOnly ? "skipped" : (bootstrapState?.state ?? "unavailable")}`);
413 if (bootstrapState?.detail) {416 if (bootstrapState?.detail) {
414 console.log(` functions detail: ${bootstrapState.detail}`);417 console.log(` functions detail: ${bootstrapState.detail}`);
415 }418 }
executor/install+10−4
@@ -367,7 +367,7 @@ start_background_services() { · 366 unmodified lines
367wait_for_executor_ready() {367wait_for_executor_ready() {
368 local max_seconds="${1:-90}"368 local max_seconds="${1:-90}"
369 local started now elapsed369 local started now elapsed
370 local doctor_interval=5370 local doctor_interval=10
371 local last_doctor_at=0371 local last_doctor_at=0
372 local backend_up=0372 local backend_up=0
373 local web_up=0373 local web_up=0
@@ -389,11 +389,17 @@ wait_for_executor_ready() { · 15 unmodified lines
389 389
390 if (( backend_up == 1 && web_up == 1 )); then390 if (( backend_up == 1 && web_up == 1 )); then
391 if (( now - last_doctor_at >= doctor_interval )); then391 if (( now - last_doctor_at >= doctor_interval )); then
392 if "$INSTALL_DIR/$APP" doctor >/dev/null 2>&1; then392 if "$INSTALL_DIR/$APP" doctor --runtime-only >/dev/null 2>&1; then
393 echo -e "${MUTED}Executor services healthy${NC}"393 echo -e "${MUTED}Executor services healthy${NC}"
394 return 0394 return 0
395 fi395 fi
396 last_doctor_at=$now396 last_doctor_at="$(date +%s)"
397
398 now="$(date +%s)"
399 elapsed=$((now - started))
400 if (( elapsed >= max_seconds )); then
401 break
402 fi
397 fi403 fi
398 doctor_ok=0404 doctor_ok=0
399 fi405 fi
@@ -402,7 +408,7 @@ wait_for_executor_ready() { · 2 unmodified lines
402 break408 break
403 fi409 fi
404 410
405 if (( elapsed > 0 && elapsed % 5 == 0 )); then411 if (( elapsed > 0 && elapsed % 10 == 0 )); then
406 if (( backend_up == 0 || web_up == 0 )); then412 if (( backend_up == 0 || web_up == 0 )); then
407 local backend_state="starting"413 local backend_state="starting"
408 local web_state="starting"414 local web_state="starting"