Skip to content

fix: detect entry script under pm2 in isMain check#36

Open
unggun wants to merge 1 commit into
yunus-0x:experimentalfrom
unggun:fix/ismain-pm2-detection
Open

fix: detect entry script under pm2 in isMain check#36
unggun wants to merge 1 commit into
yunus-0x:experimentalfrom
unggun:fix/ismain-pm2-detection

Conversation

@unggun

@unggun unggun commented May 7, 2026

Copy link
Copy Markdown

The upstream isMain check (added in 99fb060) compared path.resolve(process.argv[1]) against fileURLToPath(import.meta.url). Under pm2, process.argv[1] is pm2's ProcessContainerFork.js wrapper, not the user's script — so isMain was always false and ALL startup code (cron registration, telegram polling, hivemind bootstrap) was silently skipped. Process appeared "online" but produced zero log output and ran no work.

Fix: also accept process.env.pm_exec_path, which pm2 sets to the user's actual entry script path. Direct node index.js invocation keeps working via the original argv check.

The upstream isMain check (added in 99fb060) compared
path.resolve(process.argv[1]) against fileURLToPath(import.meta.url).
Under pm2, process.argv[1] is pm2's ProcessContainerFork.js wrapper,
not the user's script — so isMain was always false and ALL startup
code (cron registration, telegram polling, hivemind bootstrap) was
silently skipped. Process appeared "online" but produced zero log
output and ran no work.

Fix: also accept process.env.pm_exec_path, which pm2 sets to the
user's actual entry script path. Direct `node index.js` invocation
keeps working via the original argv check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant