36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
/**
|
|
* PM2 进程配置:在项目根目录执行 pm2 start ecosystem.config.cjs
|
|
* 请先创建 venv 并 pip install -r requirements.txt
|
|
*/
|
|
const path = require("path");
|
|
|
|
const isWin = process.platform === "win32";
|
|
const py = isWin
|
|
? path.join(__dirname, "venv", "Scripts", "python.exe")
|
|
: path.join(__dirname, "venv", "bin", "python");
|
|
|
|
module.exports = {
|
|
apps: [
|
|
{
|
|
name: "llm-gateway",
|
|
cwd: __dirname,
|
|
interpreter: "none",
|
|
script: py,
|
|
args: "-m uvicorn main:app --host 0.0.0.0 --port 8150",
|
|
instances: 1,
|
|
autorestart: true,
|
|
watch: false,
|
|
max_memory_restart: "500M",
|
|
env: {
|
|
NODE_ENV: "production",
|
|
// 非 TTY 下避免 stdout/stderr 被缓冲,否则 pm2 logs 长时间看不到输出
|
|
PYTHONUNBUFFERED: "1",
|
|
// 生产环境务必改为足够长的随机字符串
|
|
JWT_SECRET: "change-me-to-a-long-random-secret",
|
|
GATEWAY_PORT: "8150",
|
|
UPSTREAM_URL: "http://127.0.0.1:10434",
|
|
},
|
|
},
|
|
],
|
|
};
|