add PM2 cluster mode to utilize both CPU cores#65
Conversation
📝 WalkthroughWalkthroughThe PR adopts PM2 as the process manager: PM2 is installed globally in the Dockerfile, a new ChangesPM2 Cluster Mode Adoption
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Dockerfile (1)
15-16: Pin PM2 to an explicit version for reproducible and safer builds.
npm install -g pm2will resolve whatever is latest at build time, so rebuilds can drift unexpectedly. Pinning a tested version avoids silent runtime changes.Suggested patch
# Install PM2 globally -RUN npm install -g pm2 +ARG PM2_VERSION=7.0.1 +RUN npm install -g pm2@${PM2_VERSION}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Dockerfile` around lines 15 - 16, The RUN npm install -g pm2 command installs the latest version of PM2 at build time, making builds non-reproducible across different runs. Modify the command to pin PM2 to a specific tested version by appending `@version-number` to pm2, for example npm install -g pm2@5.x.x, ensuring consistent builds and preventing unexpected runtime changes from silent version updates.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@Dockerfile`:
- Around line 15-16: The RUN npm install -g pm2 command installs the latest
version of PM2 at build time, making builds non-reproducible across different
runs. Modify the command to pin PM2 to a specific tested version by appending
`@version-number` to pm2, for example npm install -g pm2@5.x.x, ensuring
consistent builds and preventing unexpected runtime changes from silent version
updates.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4cea12ac-745d-4e3b-a811-bdfc6e83505f
📒 Files selected for processing (4)
Dockerfileecosystem.config.cjssrc/cron.mjsstartup.sh
Summary
ecosystem.config.cjsto run 2 cluster workers via PM2 (matching the 2 vCPU server)Dockerfileto install PM2 globally andstartup.shto usepm2-runtime(keeps process in foreground for correct Docker signal handling)NODE_APP_INSTANCE === '0') to prevent duplicate deletes across workers — the flush job is already protected by a Redis distributed lockTest plan
pm2 listinside container)docker stopshuts down cleanly (no hanging processes)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Chores