vdi/web-fe/serve/ecosystem.config.js

60 lines
1.3 KiB
JavaScript

module.exports = {
apps: [
{
name: 'vdi-web',
script: 'index.js',
cwd: __dirname,
instances: 1,
exec_mode: 'fork',
env: {
NODE_ENV: 'production',
PORT: 3000
},
env_development: {
NODE_ENV: 'development',
PORT: 3000
},
// 日志配置
log_file: './logs/combined.log',
out_file: './logs/out.log',
error_file: './logs/error.log',
log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
// 自动重启配置
autorestart: true,
watch: false,
max_memory_restart: '1G',
// 启动配置
min_uptime: '10s',
max_restarts: 10,
// 监控配置
merge_logs: true,
// 优雅关闭
kill_timeout: 5000,
listen_timeout: 3000,
// 环境变量
env_production: {
NODE_ENV: 'production',
PORT: 3000
}
}
],
// 部署配置(可选)
deploy: {
production: {
user: 'node',
host: 'localhost',
ref: 'origin/main',
repo: 'git@github.com:your-repo/vdi-web.git',
path: '/var/www/vdi-web',
'pre-deploy-local': '',
'post-deploy': 'npm install && pm2 reload ecosystem.config.js --env production',
'pre-setup': ''
}
}
};