diff --git a/apps/cli/src/commands/start.ts b/apps/cli/src/commands/start.ts index b4640d5..85db636 100644 --- a/apps/cli/src/commands/start.ts +++ b/apps/cli/src/commands/start.ts @@ -26,7 +26,7 @@ export interface StartArgs { version: string; } -export function start(args: StartArgs): void { +export async function start(args: StartArgs): Promise { // 1. Initialize state directories and load env initHome(); loadEnv(); @@ -57,7 +57,7 @@ export function start(args: StartArgs): void { // 6. Ensure image (auto-build in dev, pull in npx) and start infra ensureImage(args.version); - ensureInfra(useRouter); + await ensureInfra(useRouter); // 7. Generate unique task queue and container name const suffix = randomSuffix(); diff --git a/apps/cli/src/docker.ts b/apps/cli/src/docker.ts index 972b8b3..e71aa2b 100644 --- a/apps/cli/src/docker.ts +++ b/apps/cli/src/docker.ts @@ -9,6 +9,7 @@ import { type ChildProcess, execFileSync, spawn } from 'node:child_process'; import crypto from 'node:crypto'; import os from 'node:os'; import path from 'node:path'; +import { setTimeout as sleep } from 'node:timers/promises'; import { fileURLToPath } from 'node:url'; import { getMode } from './mode.js'; @@ -78,7 +79,7 @@ function isRouterReady(): boolean { * Ensure Temporal (and optionally router) are running via compose. * If Temporal is already up but router is needed and missing, starts router only. */ -export function ensureInfra(useRouter: boolean): void { +export async function ensureInfra(useRouter: boolean): Promise { const temporalReady = isTemporalReady(); const routerNeeded = useRouter && !isRouterReady(); @@ -110,7 +111,7 @@ export function ensureInfra(useRouter: boolean): void { console.error('Timeout waiting for Temporal'); process.exit(1); } - execFileSync('sleep', ['2']); + await sleep(2000); } } @@ -122,7 +123,7 @@ export function ensureInfra(useRouter: boolean): void { console.log('Router is ready!'); return; } - execFileSync('sleep', ['2']); + await sleep(2000); } console.error('Timeout waiting for router'); process.exit(1); diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts index bceae3a..a942a82 100644 --- a/apps/cli/src/index.ts +++ b/apps/cli/src/index.ts @@ -186,7 +186,7 @@ const command = args[0]; switch (command) { case 'start': { const parsed = parseStartArgs(args.slice(1)); - start({ ...parsed, version: getVersion() }); + await start({ ...parsed, version: getVersion() }); break; } case 'stop':