@open-node/graceful v0.4.0
@open-node/graceful
Node.js process reload graceful
Installation
Usage
- your node.js process code
// defined loginfo handle function const info = console.log
const graceful = Graceful(info);
// get process status, false when existing unless will be true const status = graceful.enabled()
// regist callback when process exit graceful.exit(() => { // will be called when process exit });
// wrap function, Once the function is executed, the process will not exit until the function is executed const wrapped = graceful.runner(willBeWrappedFn); wrapped(); // Once the function is executed, the process will not exit until the function is executed
// graceful.runnerAsync is the asynchronous version of runner const wrapped = graceful.runner(willBeWrappedAsyncFn); await wrapped(); // Once the function is executed, the process will not exit until the function is executed
Table of Contents
Graceful
Parameters
info
function log info output
Returns Tick Instance
exit
regist event listenner for exiting
Parameters
listenner
function
Returns void
runner
Wrap the function sync version. Once the be wrapped function is executed, the process will not exit until the function is executed
Parameters
fn
function will be wrapped fn
Returns function Be wrapped function
runnerAsync
Wrap the function asynchronous version, Once the be wrapped function is executed, the process will not exit until the function is executed
Parameters
fn
AsyncFunction will be wrapped fn (asynchronous)
Returns function Be warpped function
enabled
The process status
Returns boolean status