Skip to content

Prestaul/on-exit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

on-exit

Easily register tasks to perform when the current node process exits.

Install

npm install on-exit

Usage

Call onExit one or more times to add process cleanup tasks:

var onExit = require('on-exit');

onExit(function() {
	console.log('Closing db connections...');
	db.close();
});

onExit(function() {
	console.log('Performing other cleanup...');
	app.cleanup();
});

When the process exits handlers will be run in the order that they were added.

Debug logs

You can set a logging function if you would like to log kill signals and exit events:

var onExit = require('on-exit').logger(function(msg) {
    myCustomLogger.log(msg);
});

// Or to console.log
onExit.logger(console.log.bind(console));

About

Register tasks to perform when the process exits

Resources

License

Stars

Watchers

Forks

Packages

No packages published