unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
21 lines • 810 B
JavaScript
function registerGracefulShutdown(unleash, logger) {
const unleashCloser = (signal) => async () => {
try {
logger.info(`Graceful shutdown signal (${signal}) received.`);
await unleash.stop();
logger.info('Unleash has been successfully stopped.');
process.exit(0);
}
catch (e) {
console.log('Exiting with code 1');
logger.error('Unable to shutdown Unleash. Hard exit!');
process.exit(1);
}
};
logger.debug('Registering graceful shutdown');
process.on('SIGINT', unleashCloser('SIGINT'));
process.on('SIGHUP', unleashCloser('SIGHUP'));
process.on('SIGTERM', unleashCloser('SIGTERM'));
}
export default registerGracefulShutdown;
//# sourceMappingURL=graceful-shutdown.js.map