Socket
Book a DemoInstallSign in
Socket

nginx-plus-dynamic-upstream

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nginx-plus-dynamic-upstream

Allows to register/unregister app in Nginx+

latest
Source
npmnpm
Version
2.2.0
Version published
Maintainers
1
Created
Source

nginx-plus-dynamic-upstream

This library allows to register/unregister app in Nginx+

Usage example

const nginxReg = new (require('nginx-plus-dynamic-upstream'))({ /* ... */ }, console);
const http     = require('http');

const server = http.createServer();
server.on('listening', () => {
   const addr = server.address();
   const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
   global.console.log('Listening on ' + bind);

   nginxReg.initHandler().catch(err => {
       console.error('Error happened during registration in Nginx. Ending execution...');
       console.error(err);
       process.exit(1);
   })
});

process.on('SIGTERM', () => exitHandler());
process.on('SIGINT', () => exitHandler());
process.on('exit', () => exitHandler());

function exitHandler() {
    console.log('Shutting down HTTP server...');

    nginxReg.exitHandler().then(() => {
        server.close();
        process.exit(0);
    }).catch(err => {
        console.error('Error happened during unregistration in Nginx. Ending execution...');
        console.error(err);
        process.exit(1);
    });
}

Keywords

nginx

FAQs

Package last updated on 09 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts