Skip to content

Commit

Permalink
Revert "In sails.lower, remove all listeners without letting the eloo…
Browse files Browse the repository at this point in the history
…p go through a cycle. This prevents ornery loops and such from displaying ugly errors on lower."

This reverts commit f61761f.
  • Loading branch information
sgress454 committed Jan 6, 2015
1 parent 892f839 commit 045fc66
Showing 1 changed file with 42 additions and 55 deletions.
97 changes: 42 additions & 55 deletions lib/app/lower.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,61 +62,48 @@ module.exports = function lower(cb) {

async.series([

/////////////////////////////////////////////////////////////////////////////////////
// Removed this in v0.11 since it seems to be handled by the removing of listeners
// below. All tests pass, but please tweet @mikermcneil if you encounter any issues.
// (the only issues we foresee would be in some kind of unexpected automated testing
// scenario)
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
//
// function shutdownSockets(cb) {
// if (!sails.hooks || !sails.hooks.sockets) {
// return cb();
// }

// try {
// log('Shutting down socket server...');
// var timeOut = setTimeout(cb, 100);
// sails.io.server.unref();
// sails.io.server.close();
// sails.io.server.on('close', function() {
// log('Socket server shut down successfully.');
// clearTimeout(timeOut);
// cb();
// });
// } catch (e) {
// clearTimeout(timeOut);
// cb();
// }
// },

// function shutdownHTTP(cb) {

// if (!sails.hooks.http) {
// return cb();
// }

// try {
// log('Shutting down HTTP server...');
// var timeOut = setTimeout(cb, 100);
// sails.hooks.http.server.unref();
// sails.hooks.http.server.close();
// sails.hooks.http.server.on('close', function() {
// log('HTTP server shut down successfully.');
// clearTimeout(timeOut);
// cb();
// });
// } catch (e) {
// clearTimeout(timeOut);
// cb();
// }
// },
//
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function shutdownSockets(cb) {
if (!sails.hooks || !sails.hooks.sockets) {
return cb();
}

try {
log('Shutting down socket server...');
var timeOut = setTimeout(cb, 100);
sails.io.server.unref();
sails.io.server.close();
sails.io.server.on('close', function() {
log('Socket server shut down successfully.');
clearTimeout(timeOut);
cb();
});
} catch (e) {
clearTimeout(timeOut);
cb();
}
},

function shutdownHTTP(cb) {

if (!sails.hooks.http) {
return cb();
}

try {
log('Shutting down HTTP server...');
var timeOut = setTimeout(cb, 100);
sails.hooks.http.server.unref();
sails.hooks.http.server.close();
sails.hooks.http.server.on('close', function() {
log('HTTP server shut down successfully.');
clearTimeout(timeOut);
cb();
});
} catch (e) {
clearTimeout(timeOut);
cb();
}
},

function removeListeners(cb) {
// Manually remove all event listeners
Expand Down

0 comments on commit 045fc66

Please sign in to comment.