How to pass arguments to app using pm2?

后端 未结 10 1188
予麋鹿
予麋鹿 2020-12-07 17:29

I am using pm2 to start my app but i am not able to pass argument to it. the command I am using is pm2 start app.js -- dev. Though this works with forever.

10条回答
  •  感动是毒
    2020-12-07 18:05

    Well there are 2 ways you can do to pass the parameters from pm2 to nodejs in CLI:

    • pm2 start app.js -- dev --port=1234 (note there is an extra space between -- and dev)
    • pm2 start app.js --node-args="dev --port=1234"

    Both ways, you will find these values exist in process.argv (['dev','--port=1234'])

提交回复
热议问题