Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const app = express();
- app.get('/', (req, res) => res.json({ ping: true }));
- const server = app.listen(3000, () => {
- console.log('Running…');
- });
- setInterval(() => server.getConnections(
- (err, connections) => console.log(`${connections} connections currently open`)
- ), 1000);
- process.on('SIGTERM', () => shutDown(server));
- process.on('SIGINT', () => shutDown(server));
- function shutDown() {
- console.log('Received kill signal, shutting down gracefully');
- server.close(() => {
- console.log('Closed out remaining connections');
- process.exit(0);
- });
- setTimeout(() => {
- console.error('Could not close connections in time, forcefully shutting down');
- process.exit(1);
- }, 10000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement