运行 foreman start 时,我看到以下消息
> foreman start
20:38:55 web.1 | started with pid 3896
20:38:55 web.1 | Development
20:38:56 web.1 | connect.multipart() will be removed in connect 3.0
20:38:56 web.1 | exited with code 1
20:38:56 system | sending SIGKILL to all processes
我想知道为什么会出现这种情况,因为运行 node server.js
似乎不会终止服务器。
以下代码段似乎会导致应用程序以退出代码 1 终止:
var app = express();
app.configure(function()
{
// More config things above
app.use(express.bodyParser()); // This line is causing the issue
// More config things below
}
以上是使用 Express.js 的代码框架。删除上面对express.bodyParser()的调用允许服务器运行(通过foreman)。问题是,我需要主体解析器模块来解析传入的 get/posts 请求。
任何有关此问题的帮助将不胜感激。
最佳答案
我不知道为什么 foreman 在 Express 中报告弃用警告时退出,但您可以消除此行为,替换 app.use(express.bodyParser());
与
app.use(express.json()); app.use(express.urlencoded());
connect.multipart()
将从 bodyParser
中删除在 Connect 的下一版本中,这可能就是问题所在。您可以在Connect documenattion中找到更多信息和/或 this StackOverflow Q&A .
关于javascript - Heroku Foreman 在 Express.js bodyParser() 调用上退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20390513/