50

How can I set the NODE_ENV variable/parameter to "production" when I'm using forever to start my node script

I got this so far:

forever start -l forever.log -o out.log -e err.log -a app.js

1 Answer 1

87

You can set NODE_ENV as normal and then run forever:

NODE_ENV=production forever [flags] start app.js [app_flags]

The initial NODE_ENV will be preserved when the server restarts - behaviour that was fixed in this issue:

https://github.com/nodejitsu/forever/issues/116

Older versions of forever can use the following command line format:

NODE_ENV=production forever [flags] app.js
Sign up to request clarification or add additional context in comments.

5 Comments

but how do i set it "as normal"?
I could have been more specific and said, "without forever" instead of "as normal". But: NODE_ENV=production forever app.js
This issue has been fixed to work on restarts: github.com/nodejitsu/forever/issues/search?q=116.
Don't know if this help, and you might have meant this with [Flags] but NODE_ENV=production forever start app.js is how I got it to work. Without it, it doesn't actually do the forever part.
@binarygiant That appears to be an update to forever's API. I'll update the original answer with the new information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.