Harold Finch Harold Finch - 4 months ago 69
Node.js Question

How to pass node v8 args and script args to pm2?

I need to be able to start the app below with pm2 but don't know how to start it with pm2.

node --expose-gc bin/www arg1 arg2 arg3

I know about
but I think is only for --expose-gc.


After some digging, I've found out that what I was looking for was the double dash on linux.

The normal code,

node --expose-gc bin/www arg1 arg2 arg3

The same code using pm2

pm2 start bin/www --node-args="--expose-gc" -- arg1 arg2 arg3

All v8 arguments you have to put inside --node-args and all scrips args to be grabbed from process.argv you have to put after the double dash.

I hope that in the future they implement something link --script-args="arg1 arg2 arg3". Would be very nice for those that isn't a linux expert.