0.2.3 • Published 6 years ago

@allegiant/shutdown v0.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

shutdown

Simple graceful shutdown helper library.

There be 🐲 here! The API and functionality are being cemented, anything before a 1.0.0 release is subject to change.

Npm Version Build Status Coverage Status

Installation

npm install @allegiant/shutdown --save

Usage

const Shutdown = require('@allegiant/shutdown');

var live=false;

Shutdown(onShutdown);
function onShutdown(req=false, finished) {
    console.log("Shut down triggered... ", req); // eslint-disable-line
    if (live !== false) {
        clearInterval(live);
        finished();
    }
}

live = setInterval(function () { 
    console.log("tick"); // eslint-disable-line
}, 1000); 

process.on('finished', function() {
    console.log("finish triggered"); // eslint-disable-line
});

Copyright & License

Copyright © 2017 Allegiant. Distributed under the terms of the MIT License, see LICENSE

Availble via npm or github.