Fix dev runner entry and sherpa TTS initialization

This commit is contained in:
Mohamed Boudra
2026-02-12 14:05:29 +07:00
parent bb93fc2a61
commit 3319c2d40c
3 changed files with 35 additions and 43 deletions

View File

@@ -2,35 +2,19 @@ import { fileURLToPath } from "url";
import { existsSync } from "node:fs";
import { runSupervisor } from "./supervisor.js";
function resolveWorkerEntry(): string {
const candidates = [
fileURLToPath(new URL("../server/server/index.js", import.meta.url)),
fileURLToPath(new URL("../dist/server/server/index.js", import.meta.url)),
fileURLToPath(new URL("../src/server/index.ts", import.meta.url)),
fileURLToPath(new URL("../../src/server/index.ts", import.meta.url)),
];
for (const candidate of candidates) {
if (existsSync(candidate)) {
return candidate;
}
}
return candidates[0];
}
function resolveWorkerExecArgv(): string[] {
const workerEntry = resolveWorkerEntry();
return workerEntry.endsWith(".ts") ? ["--import", "tsx"] : [];
const WORKER_ENTRY = fileURLToPath(new URL("../src/server/index.ts", import.meta.url));
if (!existsSync(WORKER_ENTRY)) {
throw new Error(`Dev worker entry not found: ${WORKER_ENTRY}`);
}
runSupervisor({
name: "DevRunner",
startupMessage: "Starting server worker (crash restarts enabled)",
resolveWorkerEntry,
resolveWorkerEntry: () => WORKER_ENTRY,
workerArgs: process.argv.slice(2),
workerEnv: process.env,
workerExecArgv: resolveWorkerExecArgv(),
// Always run worker with tsx so dev server uses TypeScript sources directly.
workerExecArgv: ["--import", "tsx"],
restartOnCrash: true,
shutdownReasons: ["cli_shutdown"],
});