Files
gongxue-base/ecosystem.config.cjs

33 lines
960 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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,
},
],
};