Files
gongxue-base/ecosystem.config.cjs
T

33 lines
960 B
JavaScript

// PM2 进程配置 — 恭学教育
// 用法: pm2 startOrReload ecosystem.config.cjs --update-env
// 前提: 在项目根目录执行;也可通过 DEPLOY_DIR 指定项目目录
// 生产环境配置写在项目根目录 .env,由 Nest ConfigModule 读取
// 前端构建产物 apps/admin/dist 交给 Nginx 托管,不再用 PM2 启动前端
const DEPLOY_DIR = process.env.DEPLOY_DIR || __dirname;
module.exports = {
apps: [
{
name: 'gongxue-backend',
cwd: DEPLOY_DIR,
script: 'apps/server/dist/main.js',
instances: 1,
exec_mode: 'fork',
env: {
NODE_ENV: 'production',
},
// 内存限制
max_memory_restart: '512M',
max_restarts: 10,
restart_delay: 5000,
// 日志
error_file: 'logs/backend-error.log',
out_file: 'logs/backend-out.log',
log_date_format: 'YYYY-MM-DD HH:mm:ss',
autorestart: true,
watch: false,
},
],
};