lib/server.js
/*
     * This starts the http server.
     */
This starts the http server.
This starts the http server .
startup(port, ipAddress) {
        if (_config.https) {
            this.server = https.createServer({
                cert: _config.https.cert,
                key: _config.https.key,
                ca: _config.https.ca,
                ciphers: arsenal.https.ciphers.ciphers,
                dhparam: arsenal.https.dhparam.dhparam,
                rejectUnauthorized: true,
            });
            logger.info('Https server configuration', {
                https: true,
            });
        } else {
            this.server = http.createServer();
            logger.info('Http server configuration', {
                https: false,
            });
        }
        this.server.on('connection', socket => {
            socket.on('error', err => logger.info('request rejected',
                { error: err }));
        });
        this.server.on('request', (req, res) => {
            req.socket.setNoDelay();
            routes(req, res, logger);
        });
        this.server.on('listening', () => {
            const addr = this.server.address() || {
                address: ipAddress || '[::]',
                port,
            };
            logger.info('server started', { address: addr.address,
                port: addr.port, pid: process.pid });
        });
        if (ipAddress !== undefined) {
            this.server.listen(port, ipAddress);
        } else {
            this.server.listen(port);
        }
    }
startup ( port , ipAddress ) { if ( _config . https ) { this . server = https . createServer ( { cert : _config . https . cert , key : _config . https . key , ca : _config . https . ca , ciphers : arsenal . https . ciphers . ciphers , dhparam : arsenal . https . dhparam . dhparam , rejectUnauthorized : true , } ) ; logger . info ( 'Https server configuration' , { https : true , } ) ; } else { this . server = http . createServer ( ) ; logger . info ( 'Http server configuration' , { https : false , } ) ; } this . server . on ( 'connection' , socket => { socket . on ( 'error' , err => logger . info ( 'request rejected' , { error : err } ) ) ; } ) ; this . server . on ( 'request' , ( req , res ) => { req . socket . setNoDelay ( ) ; routes ( req , res , logger ) ; } ) ; this . server . on ( 'listening' , ( ) => { const addr = this . server . address ( ) || { address : ipAddress || '[::]' , port , } ; logger . info ( 'server started' , { address : addr . address , port : addr . port , pid : process . pid } ) ; } ) ; if ( ipAddress !== undefined ) { this . server . listen ( port , ipAddress ) ; } else { this . server . listen ( port ) ; } }
This starts the http server.
This starts the http server .
// Todo: http.globalAgent.maxSockets, http.globalAgent.maxFreeSockets // disable nagle algorithm