module.exports = { apps: [ { name: 'mcp-remote-server', script: 'dist/index.js', cwd: __dirname, instances: 1, autorestart: true, watch: false, max_memory_restart: '1G', env: { NODE_ENV: 'production', PORT: 3040, HOST: '0.0.0.0', DOMAIN: 'https://mcp-browser.qubecare.ai', }, env_development: { NODE_ENV: 'development', PORT: 3040, HOST: '0.0.0.0', DOMAIN: 'http://localhost:3040', }, env_staging: { NODE_ENV: 'staging', PORT: 3040, HOST: '0.0.0.0', DOMAIN: 'https://staging-mcp-browser.qubecare.ai', }, // Logging configuration 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', // Process management min_uptime: '10s', max_restarts: 10, restart_delay: 4000, // Advanced PM2 features exec_mode: 'fork', kill_timeout: 5000, listen_timeout: 3000, // Health monitoring health_check_grace_period: 3000, // Environment-specific overrides merge_logs: true, // Build is handled by start:server script // Post-deployment hooks (optional) post_start: 'echo "MCP Remote Server started successfully"', // Graceful shutdown shutdown_with_message: true, // Source map support for better error traces source_map_support: true, // Node.js specific options node_args: '--max-old-space-size=1024', // Custom environment variables from .env file env_file: '.env', }, ], // Deployment configuration (optional) deploy: { production: { user: 'deploy', host: 'your-server.com', ref: 'origin/main', repo: 'git@github.com:your-username/your-repo.git', path: '/var/www/mcp-remote-server', 'pre-deploy-local': '', 'post-deploy': 'npm install && npm run build && pm2 reload ecosystem.config.js --env production', 'pre-setup': '', }, staging: { user: 'deploy', host: 'staging-server.com', ref: 'origin/develop', repo: 'git@github.com:your-username/your-repo.git', path: '/var/www/mcp-remote-server-staging', 'pre-deploy-local': '', 'post-deploy': 'npm install && npm run build && pm2 reload ecosystem.config.js --env staging', 'pre-setup': '', }, }, };