https://github.com/stylet/nginx-plus-dynamic-upstream
Allows to register/unregister app in Nginx+
https://github.com/stylet/nginx-plus-dynamic-upstream
Last synced: 4 months ago
JSON representation
Allows to register/unregister app in Nginx+
- Host: GitHub
- URL: https://github.com/stylet/nginx-plus-dynamic-upstream
- Owner: StyleT
- License: apache-2.0
- Created: 2019-12-19T15:05:48.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T12:38:21.000Z (over 3 years ago)
- Last Synced: 2025-03-22T14:34:48.670Z (about 1 year ago)
- Language: JavaScript
- Size: 67.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# nginx-plus-dynamic-upstream
This library allows to register/unregister app in Nginx+
## Usage example
```javascript
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);
});
}
```