node.js node/express: 使用 Forever 连续运行脚本时设置 NODE_ENV

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7674565/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 14:39:24  来源:igfitidea点击:

node/express: set NODE_ENV when using Forever to run script continuously

node.jsexpress

提问by pkyeck

How can I set the NODE_ENVvariable/parameter to "production" when I'm using foreverto start my node script

当我永远使用来启动我的节点脚本时,如何将NODE_ENV变量/参数设置为“生产”

I got this so far:

到目前为止我得到了这个:

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

回答by cjohn

You can set NODE_ENV as normal and then run forever:

您可以将 NODE_ENV 设置为正常,然后永远运行:

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

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

NODE_ENV服务器重新启动时将保留初始值- 此问题中已修复的行为:

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

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