From 4f374e575eefd0d89bad5f4a860722f26ab7f9da Mon Sep 17 00:00:00 2001 From: EgorKluch Date: Wed, 29 Jan 2014 13:30:21 +0700 Subject: [PATCH] Set keep-alive timeout --- app.js | 8 +++++++- config/config.sample.js | 1 + config/routes.js | 6 +----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 3eede36..3e16f54 100644 --- a/app.js +++ b/app.js @@ -45,7 +45,7 @@ if (cluster.isMaster) { app.use(express.cookieParser()); app.use(express.cookieSession({ - secret: 'Siht si terces yek!' + secret: config.cookieKey })); app.use(express.json()); @@ -66,7 +66,9 @@ if (cluster.isMaster) { } if (isUnexpectedError && server._handle) { + console.log('Close server'); server.close(function () { + console.log('Server was closed'); process.exit(1); }); cluster.worker.disconnect(); @@ -80,4 +82,8 @@ if (cluster.isMaster) { var server = app.listen(config.port); console.log('Express started on port ' + config.port); + + server.on('connection', function(socket) { + socket.setTimeout(150000); + }); } diff --git a/config/config.sample.js b/config/config.sample.js index 7ecf981..711b3d7 100644 --- a/config/config.sample.js +++ b/config/config.sample.js @@ -5,6 +5,7 @@ module.exports = { port: 3000, + cookieKey: 'secret', mysql: { host: 'localhost', diff --git a/config/routes.js b/config/routes.js index 97e6ae3..ec0fdb9 100644 --- a/config/routes.js +++ b/config/routes.js @@ -27,11 +27,7 @@ module.exports = function (app) { var getRouteHandler = function (context, method) { return function (req, res, next) { - try { - method.call(context, req.core, next); - } catch (err) { - next(new AppError(err)); - } + method.call(context, req.core, next); } };