Files
gongxue-base/ecosystem.config.cjs

54 lines
1.5 KiB
JavaScript
Raw 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 start ecosystem.config.cjs
// 前提: 项目部署在 /opt/gongxuedeploy.sh 默认路径)
// .env 文件在 /opt/gongxue/.env
// docker compose up -d 已启动 MySQL
const DEPLOY_DIR = process.env.DEPLOY_DIR || '/opt/gongxue';
module.exports = {
apps: [
{
name: 'gongxue-backend',
cwd: DEPLOY_DIR,
script: 'apps/server/dist/main.js',
instances: 1,
exec_mode: 'fork',
env: {
NODE_ENV: 'production',
PORT: '3000',
DB_TYPE: 'mysql',
DB_HOST: '127.0.0.1',
DB_PORT: '3306',
DB_USERNAME: 'root',
DB_PASSWORD: 'gongxue_2024',
DB_DATABASE: 'gongxue',
DB_SYNCHRONIZE: 'true',
JWT_SECRET: 'gongxue-jwt-prod-2026-k3y',
JWT_EXPIRES_IN: '24h',
UPLOAD_DIR: './uploads',
DINGTALK_APP_KEY: 'dingvpcg2i6p25ftxw5c',
DINGTALK_APP_SECRET: 'ovAEql1r5Lu9FvBve6bHwBZxXAZuEQwSNpG3DkRJk4DMhQwJ_raKDQc6emdlJisU',
},
// 内存限制
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,
},
{
name: 'gongxue-frontend',
cwd: DEPLOY_DIR,
script: 'serve-proxy.js',
env: {
NODE_ENV: 'production',
},
},
],
};