Files
moyosapp_beta.0.0.3.3_beta1/ecosystem.config.js
2026-01-16 19:04:48 +02:00

79 lines
1.8 KiB
JavaScript

/**
* PM2 Ecosystem Configuration
*
* This file configures PM2 to run the Next.js application in cluster mode
* for better performance and reliability.
*
* Usage:
* pm2 start ecosystem.config.js
* pm2 save
* pm2 startup
*/
module.exports = {
apps: [{
name: 'moyos-wedding-app',
script: 'npm',
args: 'start',
// Cluster mode for load distribution
instances: 2,
exec_mode: 'cluster',
// Environment variables
env: {
NODE_ENV: 'production',
PORT: 3000,
},
// Logging
error_file: './logs/err.log',
out_file: './logs/out.log',
log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
merge_logs: true,
time: true,
// Resource limits
max_memory_restart: '2G',
// Auto-restart configuration
autorestart: true,
watch: false,
max_restarts: 10,
min_uptime: '10s',
restart_delay: 4000,
// Graceful shutdown
kill_timeout: 5000,
wait_ready: true,
listen_timeout: 10000,
// Advanced options
instance_var: 'INSTANCE_ID',
// Health check (if using PM2 Plus/Monitoring)
// pmx: true,
}],
// Deployment configuration (optional)
deploy: {
production: {
user: 'deploy',
host: 'your-server.com',
ref: 'origin/main',
repo: 'git@github.com:your-org/moyos-wedding-app.git',
path: '/opt/moyos-wedding-app',
'post-deploy': 'npm ci && npm run build && pm2 reload ecosystem.config.js --env production',
'pre-setup': 'apt-get update && apt-get install -y git',
},
staging: {
user: 'deploy',
host: 'staging-server.com',
ref: 'origin/develop',
repo: 'git@github.com:your-org/moyos-wedding-app.git',
path: '/opt/moyos-wedding-app-staging',
'post-deploy': 'npm ci && npm run build && pm2 reload ecosystem.config.js --env staging',
},
},
};