github-actions[bot]
deploy prod from 06dbd16a01ddcfe02b2d936c681e3e4eaa9b141f
8e756fd
Raw
History Blame Contribute Delete
1.26 kB
import { spawn } from "node:child_process";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { startApiWithReload, waitForApiReady } from "./api-reload.mjs";
const here = path.dirname(fileURLToPath(import.meta.url));
const frontendDir = path.resolve(here, "..");
const repoRoot = path.resolve(frontendDir, "../../../..");
const apiOnly = process.argv.includes("--api-only");
function run(command, args, options = {}) {
return spawn(command, args, {
stdio: "inherit",
...options,
});
}
const api = startApiWithReload(repoRoot);
if (apiOnly) {
process.on("SIGINT", () => {
api.stop();
process.exit(0);
});
process.on("SIGTERM", () => {
api.stop();
process.exit(0);
});
} else {
console.log("[dev] Waiting for Python API on port 8765…");
await waitForApiReady(api.port);
console.log("[dev] API ready — starting Vite");
const vite = run("npm", ["run", "dev:vite"], { cwd: frontendDir, shell: true });
const shutdown = () => {
api.stop();
vite.kill("SIGTERM");
};
process.on("SIGINT", shutdown);
process.on("SIGTERM", shutdown);
Promise.all([
new Promise((resolve) => vite.on("exit", resolve)),
]).then(() => {
api.stop();
process.exit(0);
});
}