node / express:使用Forever连续运行脚本时设置NODE_ENV
问题描述:
当我使用 NODE_ENV 变量/参数设置为production https://github.com/indexzero/forever\">forever 启动我的节点脚本
how can i set the NODE_ENV variable/parameter to "production" when i'm using forever to start my node script
我到目前为止:
forever start -l forever.log -o out.log -e err.log -a app.js
答
您可以将NODE_ENV设置为正常,然后永久运行:
You can set NODE_ENV as normal and then run forever:
NODE_ENV=production forever [flags] start app.js [app_flags]
初始 NODE_ENV
将在服务器重新启动时被保留 - 在此问题中修复的行为:
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