Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function _clusterMaster(context) {
const logger = makeLogger(context, 'cluster_master');
const clusterConfig = context.sysconfig.teraslice;
const assetsPort = process.env.assets_port;
const assetsUrl = `http://127.0.0.1:${assetsPort}`;
let running = false;
// Initialize the HTTP service for handling incoming requests.
const app = express();
const clusterMasterServer = new ClusterMaster.Server({
port: clusterConfig.port,
nodeDisconnectTimeout: clusterConfig.node_disconnect_timeout,
// setting request timeout to 5 minutes
serverTimeout: 300000,
// we do this to override express final response handler
requestListener(req, res) {
app(req, res, (err) => {
if (err) logger.warn(err, 'unexpected server error');
res.setHeader('Content-Type', 'application/json');
res.statusCode = 500;
res.end(JSON.stringify({ error: 'api is not available' }));
});
},
networkLatencyBuffer: clusterConfig.network_latency_buffer,
actionTimeout: clusterConfig.action_timeout,
logger,