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
344344
345345 async function runDoctor(args: string[]): Promise<number> {
346346 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");
348349 if (unknownArgs.length > 0) {
349350 console.log(`Unknown option: ${unknownArgs[0]}`);
350351 return 1;
@@ -358,17 +359,19 @@ async function runDoctor(args: string[]): Promise<number> { · 7 unmodified lines
358359 const webRunning = await checkHttp(`http://127.0.0.1:${webPort}/`);
359360
360361 let bootstrapState: Awaited<ReturnType<typeof checkBootstrapHealth>> | null = null;
361− if (backendRunning) {
362+ if (backendRunning && !runtimeOnly) {
362363 bootstrapState = await checkBootstrapHealth(info);
363364 }
364365
365− const functionsReady = bootstrapState?.state === "ready";
366+ const functionsReady = runtimeOnly ? true : bootstrapState?.state === "ready";
366367 const healthy = nodeInstalled && webInstalled && backendRunning && webRunning && functionsReady;
367368
368369 console.log(`Executor status: ${healthy ? "ready" : "needs attention"}`);
369370 console.log(`Dashboard: http://127.0.0.1:${webPort} (${webRunning ? "running" : "not running"})`);
370371 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) {
372375 console.log("Functions: unavailable (backend is not running)");
373376 } else if (bootstrapState?.state === "ready") {
374377 console.log("Functions: bootstrapped");
@@ -387,13 +390,13 @@ async function runDoctor(args: string[]): Promise<number> { · 12 unmodified lines
387390 if (!webRunning) {
388391 console.log("Next step: run `executor web`");
389392 }
390− if (backendRunning && bootstrapState?.state === "no_project") {
393+ if (!runtimeOnly && backendRunning && bootstrapState?.state === "no_project") {
391394 console.log("Next step: run from your repo root or set `EXECUTOR_PROJECT_DIR` to a Convex project.");
392395 }
393− if (backendRunning && bootstrapState?.state === "missing_functions") {
396+ if (!runtimeOnly && backendRunning && bootstrapState?.state === "missing_functions") {
394397 console.log("Next step: run `executor up` from your project root to bootstrap functions.");
395398 }
396− if (backendRunning && bootstrapState?.state === "check_failed") {
399+ if (!runtimeOnly && backendRunning && bootstrapState?.state === "check_failed") {
397400 console.log("Next step: run `executor up` and inspect ~/.executor/runtime/logs/backend.log");
398401 }
399402 if (!webInstalled || !nodeInstalled) {
@@ -409,7 +412,7 @@ async function runDoctor(args: string[]): Promise<number> { · 9 unmodified lines
409412 console.log(` convex site: ${info.convexSiteUrl}`);
410413 console.log(` node runtime: ${nodeInstalled ? info.nodeBin : "missing"}`);
411414 console.log(` web bundle: ${webInstalled ? info.webServerEntry : "missing"}`);
412− console.log(` functions: ${bootstrapState?.state ?? "unavailable"}`);
415+ console.log(` functions: ${runtimeOnly ? "skipped" : (bootstrapState?.state ?? "unavailable")}`);
413416 if (bootstrapState?.detail) {
414417 console.log(` functions detail: ${bootstrapState.detail}`);
415418 }
executor/install+10−4
@@ -367,7 +367,7 @@ start_background_services() { · 366 unmodified lines
367367 wait_for_executor_ready() {
368368 local max_seconds="${1:-90}"
369369 local started now elapsed
370− local doctor_interval=5
370+ local doctor_interval=10
371371 local last_doctor_at=0
372372 local backend_up=0
373373 local web_up=0
@@ -389,11 +389,17 @@ wait_for_executor_ready() { · 15 unmodified lines
389389
390390 if (( backend_up == 1 && web_up == 1 )); then
391391 if (( now - last_doctor_at >= doctor_interval )); then
392− if "$INSTALL_DIR/$APP" doctor >/dev/null 2>&1; then
392+ if "$INSTALL_DIR/$APP" doctor --runtime-only >/dev/null 2>&1; then
393393 echo -e "${MUTED}Executor services healthy${NC}"
394394 return 0
395395 fi
396− last_doctor_at=$now
396+ last_doctor_at="$(date +%s)"
397+
398+ now="$(date +%s)"
399+ elapsed=$((now - started))
400+ if (( elapsed >= max_seconds )); then
401+ break
402+ fi
397403 fi
398404 doctor_ok=0
399405 fi
@@ -402,7 +408,7 @@ wait_for_executor_ready() { · 2 unmodified lines
402408 break
403409 fi
404410
405− if (( elapsed > 0 && elapsed % 5 == 0 )); then
411+ if (( elapsed > 0 && elapsed % 10 == 0 )); then
406412 if (( backend_up == 0 || web_up == 0 )); then
407413 local backend_state="starting"
408414 local web_state="starting"