chore: split local development services
This commit is contained in:
+2
-21
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
// dev-backend: 启动 PostgreSQL 依赖,并连接宿主机 native browser gateway 后运行 control-plane。
|
||||
import { spawn, spawnSync } from "node:child_process";
|
||||
// backend: 运行带 Air 热加载的 Go control-plane。
|
||||
import { spawn } from "node:child_process";
|
||||
import { readFileSync, existsSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import path from "node:path";
|
||||
@@ -37,25 +37,6 @@ if (!overrides.LOG_LEVEL) overrides.LOG_LEVEL = "debug";
|
||||
if (!overrides.NATIVE_GATEWAY_ENDPOINT) overrides.NATIVE_GATEWAY_ENDPOINT = "http://127.0.0.1:8081";
|
||||
|
||||
const env = { ...process.env, ...overrides };
|
||||
const compose = spawnSync(
|
||||
"docker",
|
||||
["compose", "-f", "compose.yaml", "-f", "compose.dev.yaml", "up", "-d", "postgres"],
|
||||
{ cwd: root, env, stdio: "inherit" },
|
||||
);
|
||||
if (compose.status !== 0) {
|
||||
console.error("启动 PostgreSQL 容器失败,请确认 Docker 只用于数据库依赖。");
|
||||
process.exit(compose.status ?? 1);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${overrides.NATIVE_GATEWAY_ENDPOINT}/healthz`, { signal: AbortSignal.timeout(2000) });
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
} catch (error) {
|
||||
console.error(`[dev-backend] native browser gateway 不可达:${overrides.NATIVE_GATEWAY_ENDPOINT} (${error})`);
|
||||
console.error("请先以非 root 用户启动 browser_gateway.server.http 或对应的 systemd user service。");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const air = spawn("air", ["-c", ".air.toml", ...process.argv.slice(2)], {
|
||||
cwd: root,
|
||||
env,
|
||||
|
||||
Reference in New Issue
Block a user