Commit 63cac738 authored by Anton Veshnyakov's avatar Anton Veshnyakov

logger error catcher

http max sockets config
parent eaccac7a
......@@ -78,7 +78,7 @@ function sendMail (recipients = config.get('couchbox.mail.recipients'), mailMess
function fatal_action(errorMessage) {
if (config.get('couchbox.mail.active')) {
const subj = 'Node '+ config.get('couchbox.nodename') +' - Fatal Alert';
if ('error' in errorMessage) {
if (errorMessage.hasOwnProperty('error')) {
try {
const error = JSON.parse(errorMessage.error);
if (error && error.message && error.stack) {
......
......@@ -4,7 +4,6 @@ const http = require('http');
const Bucket = require('./bucket');
const Router = require('./router');
const Sessions = require('./sessions');
const lib = require('../../utils/lib');
const Logger = require('../../utils/logger');
const config = require('../../config');
......@@ -69,6 +68,12 @@ function API(props = {}) {
})
});
// Max sockets param
if (config.get('api.maxSockets') && config.get('api.maxSockets') > 0) {
http.globalAgent.maxSockets = config.get('api.maxSockets')|0;
} else {
http.globalAgent.maxSockets = Infinity;
}
// Server
const server = http.createServer(router.onRequest);
......
const lib = require('../../utils/lib');
const Worker = require('../../utils/worker');
const API = require('./api');
const configValidator = require('./configValidator');
......
......@@ -146,7 +146,12 @@ function Router(props = {}) {
const routes = new Map();
const paths = {};
const proxyHTTP = httpProxy.createProxyServer({}).on('proxyReq', function onProxyReq(proxyReq, req, res, options) {
const proxyHTTP = httpProxy.createProxyServer({});
proxyHTTP.on('error', function onProxyError(err, req, res) {
res.writeHead(500, { 'Content-Type': 'text/plain' });
res.end('Server error');
});
proxyHTTP.on('proxyReq', function onProxyReq(proxyReq, req) {
let remoteAddress;
if (req.connection) {
if (req.connection.remoteAddress) remoteAddress = req.connection.remoteAddress;
......@@ -448,7 +453,6 @@ function Router(props = {}) {
return resolve(result);
});
});
}
function onHandlerError(error) {
......
const http = require('http');
const httpProxy = require('http-proxy');
const Logger = require('../../utils/logger');
const lib = require('../../utils/lib');
const config = require('../../config');
const {
......@@ -39,6 +39,14 @@ function ProxyWorker(props = {}) {
let lastApiWorker = 0;
const maxApiWorker = API_PORTS.length;
// Max sockets param
if (config.get('proxy.maxSockets') && config.get('proxy.maxSockets') > 0) {
http.globalAgent.maxSockets = config.get('proxy.maxSockets')|0;
} else if (config.get('api.maxSockets') && config.get('api.maxSockets') > 0) {
http.globalAgent.maxSockets = config.get('api.maxSockets')|0;
} else {
http.globalAgent.maxSockets = Infinity;
}
const getApiWorker = () => ({
host: 'localhost',
......
const lib = require('../../utils/lib');
const Worker = require('../../utils/worker');
const Socket = require('./socket');
const configValidator = require('./configValidator');
......
......@@ -19,6 +19,15 @@ function Socket(props = {}) {
const logger = new Logger({ prefix: 'Socket', logger: props.logger });
const log = logger.getLog();
// Max sockets param
if (config.get('socket.maxSockets') && config.get('socket.maxSockets') > 0) {
http.globalAgent.maxSockets = config.get('socket.maxSockets')|0;
} else if (config.get('api.maxSockets') && config.get('api.maxSockets') > 0) {
http.globalAgent.maxSockets = config.get('api.maxSockets')|0;
} else {
http.globalAgent.maxSockets = Infinity;
}
const server = http.Server();
const io = socketio(server, { path: SOCKET_PATH });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment