Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:03
What would you like to do?
System resources and cooperative process exit
(function(COMPOSITE) {
//Load our dependencies
var util = require('util');
var events = require('events');
var RSVP = require('rsvp');
COMPOSITE.Process = new events.EventEmitter;
//Before we get interrupted, close resources
process.on('SIGINT', function() {
var toShutdown = []
var processFn = function (shutdownProcess) {
COMPOSITE.Process.emit('exit', processFn);
RSVP.all(toShutdown).then(function() {
console.log('everything shutdown...exiting');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment