module.exports = { apps: [{ name: 'digitalHuman-websocketTask-v2', script: './webSocket.js', cwd: './', args: '', interpreter: 'node', interpreter_args: '', // 监听文件修改 watch: true, ignore_watch: ['logs', 'node_modules', 'static', 'package.json', 'package-lock.json', 'pnpm-lock.yaml', 'index.js', 'outside/callback.js', 'pm2Index.config.cjs', 'pm2Websocket.config.cjs'], // 实例数 - 单实例建议使用 fork 模式 instances: 1, exec_mode: 'fork', // cluster 模式下日志轮转需要特殊处理,单实例用 fork 更稳定 // 自动重启设置 autorestart: true, max_restarts: 30, min_uptime: '10s', // 内存限制重启 // max_memory_restart: '1G', // 日志配置 - 移除原生 logrotate 配置(改用插件) out_file: './logs/websocket/out/out.log', error_file: './logs/websocket/error/error.log', log_type: 'raw', log_date_format: 'YYYY-MM-DD HH:mm:ss Z', // 监控和重启设置 kill_timeout: 1600, restart_delay: 4000, // 环境变量 env_production: { NODE_ENV: 'production', PORT: 8080 } }] };