-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecosystem.config.js
More file actions
125 lines (109 loc) · 3.21 KB
/
ecosystem.config.js
File metadata and controls
125 lines (109 loc) · 3.21 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
116
117
118
119
120
121
122
123
124
125
// PM2 Ecosystem Configuration for Soulfield OS
// Usage: pm2 start ecosystem.config.js
module.exports = {
apps: [
{
name: 'soulfield-os',
script: 'backend/index.cjs',
cwd: '/home/michael/soulfield',
// Environment
env: {
NODE_ENV: 'production',
PORT: 8790,
LENS_ENFORCEMENT_MODE: 'adaptive',
LENS_AUTO_FIX: 'true',
LENS_VERBOSE_ERRORS: 'false',
},
// Process Management
instances: 1,
exec_mode: 'fork', // Use 'cluster' for multi-instance when scaling
// Auto-restart Configuration
autorestart: true,
watch: false, // Enable in development: ['backend/**/*.cjs', 'backend/**/*.js']
max_memory_restart: '1G',
// Restart Policy
min_uptime: '10s', // Minimum uptime before considering successful
max_restarts: 10, // Max restart attempts within restart_delay window
restart_delay: 4000, // Wait 4s between restarts
// Logging
error_file: './logs/soulfield-error.log',
out_file: './logs/soulfield-out.log',
log_file: './logs/soulfield-combined.log',
time: true, // Prefix logs with timestamp
log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
merge_logs: true,
// Advanced Options
kill_timeout: 5000, // Time to wait for graceful shutdown
listen_timeout: 3000, // Time to wait for listen event
shutdown_with_message: true,
// Performance Monitoring
instance_var: 'INSTANCE_ID',
// PM2+ Monitoring (if using PM2 Plus)
// pmx: true,
// Graceful Shutdown
wait_ready: false,
// Source Maps (for better error traces)
source_map_support: false,
// Environment-Specific Overrides
env_development: {
NODE_ENV: 'development',
LENS_ENFORCEMENT_MODE: 'soft',
LENS_VERBOSE_ERRORS: 'true',
},
env_staging: {
NODE_ENV: 'staging',
LENS_ENFORCEMENT_MODE: 'adaptive',
},
env_production: {
NODE_ENV: 'production',
LENS_ENFORCEMENT_MODE: 'adaptive',
LENS_VERBOSE_ERRORS: 'false',
},
},
],
// Deployment Configuration (optional)
deploy: {
production: {
user: 'michael',
host: 'localhost',
ref: 'origin/main',
repo: 'git@github.com:your-org/soulfield.git', // Update with actual repo
path: '/home/michael/soulfield',
'post-deploy': 'npm install && pm2 reload ecosystem.config.js --env production',
'pre-deploy-local': 'git status',
},
},
};
/**
* PM2 Commands Reference:
*
* Start:
* pm2 start ecosystem.config.js
* pm2 start ecosystem.config.js --env production
*
* Monitor:
* pm2 monit
* pm2 status
* pm2 logs soulfield-os
* pm2 logs soulfield-os --lines 100
*
* Restart:
* pm2 restart soulfield-os
* pm2 reload soulfield-os // Zero-downtime restart
*
* Stop:
* pm2 stop soulfield-os
* pm2 delete soulfield-os // Remove from PM2
*
* Save Configuration:
* pm2 save // Save current process list
* pm2 startup // Generate startup script
*
* Metrics:
* pm2 describe soulfield-os
* pm2 env 0 // Show environment variables
*
* Logs:
* pm2 flush // Clear all logs
* pm2 reloadLogs // Reload log files
*/