arguments and options from cli are passed to the forked child process
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
env: nodejs: v16.14.3 pm2: v5.2.0
I tried to pass the arguments and options to my app script, like the following
pm2 start app.js --no-deamon -- ./entry.js --config ./config/prod.js
If I print process.argv in app.js, the result will be
["start", "app.js", "--no-daemon", "--", "./entry.js", "--config", "./config/prod.js", "./entry.js", "--config", "./config/prod.js"]
(ignore argv[0] and argv[1])
In my situation, the app script is in a npm package, it need a argument and a option to specific its entry and config. It is clear that I get wrong process.argv. My app script launch as
app.js ./entry.js --config ./config/prod.js
Using pm2, it will be
app.js start app.js --no-daemon ...(ignore)
In usually, arguments and options after -- should be ignore in current process and pass to the next process, but pm2 not.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported command with Node.js v16.14.3 and PM2 v5.2.0, then trace the CLI argument parsing and child-process launch path. Done means arguments and options after -- are passed once to the app without PM2's own command arguments appearing in process.argv.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100