无法加载网页,因为服务器未发送任何数据。 错误代码:ERR_EMPTY_RESPONSE
我的本地NodeJS设置间歇性地变得无法响应。当我刷新我的电脑它工作正常但它不断给我以下消息。我的代码中的任何内容都会尖叫错误。
//dependencies
var path = require('path');
var express = require('express');
var http = require('http');
var mongoose = require('mongoose');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var schemas = require('./schemas/schemas');
//main config
var app = express();
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.set('view options', {
layout: false
});
app.use(express.logger());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('BodySnatchingLizardPPL'));
app.use(express.session());
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.configure('development', function () {
app.use(express.errorHandler({
dumpExceptions: true,
showStack: true
}));
});
app.configure('production', function () {
app.use(express.errorHandler());
});
//passport config
var Account = require('./models/account');
passport.use(new LocalStrategy(Account.authenticate()));
passport.serializeUser(Account.serializeUser());
passport.deserializeUser(Account.deserializeUser());
//mongoose
mongoose.connect('mongodb://demo2:demo2@ds033699.mongolab.com:33699/nicksdbthing');
require("fs").readdirSync("./routes_data_get/").forEach(function(file) {
require("./routes_data_get/" + file)(app);
});
require("fs").readdirSync("./routes_data_post/").forEach(function(file) {
require("./routes_data_post/" + file)(app);
});
require("fs").readdirSync("./routes_data_post/").forEach(function(file) {
require("./routes_data_post/" + file)(app);
});
app.listen(app.get('port'), function () {
console.log(("Express server listening on port " + app.get('port')))
});