Commit 4fc3339
Fix PM2 cluster mode environment variable loading (#379)
Problem:
- When running with `pm2 start` in cluster mode, Node.js 22's --env-file flag was not being passed
- This caused all process.env variables to be undefined, breaking database connections and app configuration
- The issue only occurred in PM2 deployments; npm start worked correctly
Solution:
- Created ecosystem.config.js to configure PM2 with proper node_args
- Added --env-file=config.env --env-file=.env flags to node_args
- Updated CI/CD workflows (cd_dev.yaml and cd_prod.yaml) to use ecosystem config
- Configured separate development and production environments
Changes:
- NEW: ecosystem.config.js - PM2 configuration with cluster mode and env loading
- UPDATED: .github/workflows/cd_dev.yaml - Use ecosystem config for development deployment
- UPDATED: .github/workflows/cd_prod.yaml - Use ecosystem config for production deployment
Testing:
- Local: pm2 start ecosystem.config.js --env development
- Verify env variables load: process.env values should be defined from config.env and .env
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>1 parent 5e88be0 commit 4fc3339
3 files changed
Lines changed: 45 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments