Running Node.js using forever with --nouse-idle-notification and other flags

I used to start my node application with:

NODE_ENV=production forever start index.js 

However, as suggested in this question , I would like to start node using -nouse-idle-notification. I also found this tuning article - max-old-space-size, etc. Unfortunately, no one I ask may seem to determine if the flag is really accepted by the node, so I'm not sure how to determine the correctness of my forever syntax.

Also, I cannot accept both arguments forever ...

For example, if I use this

 NODE_ENV=production forever start --max-old-space-size=8192 --nouse-idle-notification index.js 

I get "perpetual usage information" as if I were trying to start forever without transferring the .js file to run (for example, just by typing "forever"). If I put the flags in front of the "start" command, this seems to start, but again I'm not sure how to determine if the flags were accepted ...

Can someone help me with the correct syntax?

+6
source share
3 answers

You need to pass the -c option:

 forever start -c "node --max-old-space-size=8192 --nouse-idle-notification" index.js 

If you list the processes, you will see that the flags are respected.

 forever list 
+14
source

If you really don't love forever for any other reason, try mon .

It is very easy to pass flags, because you can specify the exact command:

 mon "node --max-old-space-size=8192 --nouse-idle-notification --expose-gc server.js" -d 

It controls only the node process. If you want to control a group of processes, as this happens forever, install mongroup , its bash script, which controls mon .

This will save you some RAM, especially if you are tracking a lot of node processes (I think that it starts forever one additional node process for each process that you want to control).

quick tip: the last time I checked, the TJ Holowaychuk mon branch didn’t work well under Linux (I think it tested only on Mac), but this one works, and the one I'm using right now. EDIT : In fact, 2 days ago the problem was closed, and now the main unit should work.

+1
source

You may try:

 forever start --max-old-space-size=8192 --nouse-idle-notification -c "NODE_ENV=production node" index.js 
-1
source

Source: https://habr.com/ru/post/927774/


All Articles