Node.js forever with environment variable

First of all you should skip the node thing in you command, it should not be there, you should not be able to execute that. forever automatically starts your script using nodejs. Instead you should do like this;

sudo IS_PROD=1 forever app.js

Probably you, instead of starting your server in foreground, will want to start your server as a daemon. eg.

sudo IS_PROD=1 forever start app.js

This will create a process in the background that will watch your node app and restart it when it exits. For more information see the readme.

Both of these methods preserves the environment variables, just like when you are just using node.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)