36 lines
905 B
JavaScript
36 lines
905 B
JavaScript
|
|
module.exports = {
|
||
|
|
apps: [
|
||
|
|
{
|
||
|
|
name: 'gamegroup-backend',
|
||
|
|
script: './dist/main.js',
|
||
|
|
instances: 'max', // 使用所有CPU核心
|
||
|
|
exec_mode: 'cluster', // 集群模式
|
||
|
|
env: {
|
||
|
|
NODE_ENV: 'development',
|
||
|
|
},
|
||
|
|
env_production: {
|
||
|
|
NODE_ENV: 'production',
|
||
|
|
},
|
||
|
|
// 日志配置
|
||
|
|
error_file: './logs/pm2-error.log',
|
||
|
|
out_file: './logs/pm2-out.log',
|
||
|
|
log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
|
||
|
|
merge_logs: true,
|
||
|
|
|
||
|
|
// 进程管理
|
||
|
|
watch: false, // 生产环境不启用文件监视
|
||
|
|
max_memory_restart: '500M', // 内存超过500M自动重启
|
||
|
|
|
||
|
|
// 自动重启配置
|
||
|
|
autorestart: true,
|
||
|
|
max_restarts: 10,
|
||
|
|
min_uptime: '10s',
|
||
|
|
|
||
|
|
// 优雅关闭
|
||
|
|
kill_timeout: 5000,
|
||
|
|
wait_ready: true,
|
||
|
|
listen_timeout: 3000,
|
||
|
|
},
|
||
|
|
],
|
||
|
|
};
|