-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecosystem.config.js
More file actions
115 lines (97 loc) · 2.65 KB
/
ecosystem.config.js
File metadata and controls
115 lines (97 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
module.exports = {
apps: [{
name: 'stack-blog',
script: './app.js',
instances: 'max',
exec_mode: 'cluster',
// Environment configuration
env: {
NODE_ENV: 'development',
PORT: 3000
},
env_production: {
NODE_ENV: 'production',
PORT: 3000
},
env_staging: {
NODE_ENV: 'staging',
PORT: 3001
},
// Logging configuration
error_file: './logs/err.log',
out_file: './logs/out.log',
log_file: './logs/combined.log',
time: true,
// Memory and performance
max_memory_restart: '512M',
node_args: '--max-old-space-size=512',
// Graceful shutdown and restart
kill_timeout: 5000,
wait_ready: true,
listen_timeout: 10000,
// Auto restart configuration
autorestart: true,
max_restarts: 10,
min_uptime: '10s',
// File watching (disabled in production)
watch: false,
ignore_watch: [
'node_modules',
'logs',
'content/media',
'.git',
'__tests__'
],
// Source map support
source_map_support: true,
// Merge logs from all instances
merge_logs: true,
// Instance variables
instance_var: 'INSTANCE_ID',
// Health check endpoint
health_check_path: '/api/status',
health_check_grace_period: 3000,
// Cron restart (optional - restart daily at 4 AM)
cron_restart: '0 4 * * *',
// Advanced PM2 features
pmx: true,
automation: false,
// Environment-specific overrides
env_development: {
NODE_ENV: 'development',
LOG_LEVEL: 'debug',
CACHE_ENABLED: 'false'
}
}],
// Deployment configuration
deploy: {
production: {
user: 'stackblog',
host: ['your-server.com'],
ref: 'origin/main',
repo: 'https://github.com/audit-brands/stack_blog.git',
path: '/home/stackblog/stack_blog',
// Pre-deployment hooks
'pre-deploy-local': 'echo "Starting deployment..."',
'pre-deploy': 'git reset --hard && git clean -fd',
// Post-deployment hooks
'post-deploy': 'npm ci --production && pm2 reload ecosystem.config.js --env production',
'post-setup': 'ls -la',
// Environment variables for deployment
env: {
NODE_ENV: 'production'
}
},
staging: {
user: 'stackblog',
host: ['staging-server.com'],
ref: 'origin/develop',
repo: 'https://github.com/audit-brands/stack_blog.git',
path: '/home/stackblog/stack_blog_staging',
'post-deploy': 'npm ci && pm2 reload ecosystem.config.js --env staging',
env: {
NODE_ENV: 'staging'
}
}
}
};