diff --git a/lib/app/lower.js b/lib/app/lower.js index c6d59acdd..6f2115e98 100644 --- a/lib/app/lower.js +++ b/lib/app/lower.js @@ -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