mirror of
https://github.com/2234839/web-font.git
synced 2026-04-29 21:00:45 +08:00
- 修复 multipart 解析器:endDelimiter 提前检查导致循环退出 - 修复 Node.js v24 兼容:改为先读取 body 再构造 Request - 修复 HTTP keep-alive 死锁:按 Content-Length 精确读取 body - 修复服务器崩溃:connectionHandle 加 try-catch,单连接错误不影响全局 - 修复 URL 写死:webfont.shenzilong.com 改为 localhost - 复制按钮加"已复制/复制失败"反馈提示 - TEMP_MAX_FILES 改为环境变量可配置 - dev 环境默认启用临时上传和管理员上传 - CSS 代码默认展示,使用技巧不再折叠 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
/**
|
|
* 同时启动前端 (vite) 和后端 (tsx backend/app.ts) 的开发服务器
|
|
* Ctrl+C 会同时终止两个进程
|
|
*/
|
|
import { spawn } from "node:child_process";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const ROOT_DIR = join(__dirname, "..");
|
|
|
|
/** 子进程列表,用于退出时统一清理 */
|
|
const children: ReturnType<typeof spawn>[] = [];
|
|
|
|
/** 清理所有子进程 */
|
|
function cleanup() {
|
|
for (const child of children) {
|
|
child.kill("SIGTERM");
|
|
}
|
|
}
|
|
|
|
process.on("SIGINT", () => {
|
|
cleanup();
|
|
process.exit(0);
|
|
});
|
|
process.on("SIGTERM", () => {
|
|
cleanup();
|
|
process.exit(0);
|
|
});
|
|
|
|
console.log("Starting frontend and backend dev servers...\n");
|
|
|
|
const backend = spawn("pnpx", ["tsx", "watch", "backend/app.ts"], {
|
|
cwd: ROOT_DIR,
|
|
stdio: "inherit",
|
|
shell: true,
|
|
env: { ...process.env, ENABLE_TEMP_UPLOAD: "true", ADMIN_API_KEY: "dev-key" },
|
|
});
|
|
children.push(backend);
|
|
|
|
const frontend = spawn("pnpm", ["dev:frontend"], {
|
|
cwd: ROOT_DIR,
|
|
stdio: "inherit",
|
|
shell: true,
|
|
});
|
|
children.push(frontend);
|