mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 23:45:45 +01:00
cleanly shutdown
wait for webserver to stop accepting connections destroy current connections wait for db connection to close
This commit is contained in:
24
src/start.js
24
src/start.js
@@ -153,11 +153,21 @@ function restart() {
|
||||
|
||||
function shutdown(code) {
|
||||
winston.info('[app] Shutdown (SIGTERM/SIGINT) Initialised.');
|
||||
require('./database').close();
|
||||
winston.info('[app] Database connection closed.');
|
||||
require('./webserver').server.close();
|
||||
winston.info('[app] Web server closed to connections.');
|
||||
|
||||
winston.info('[app] Shutdown complete.');
|
||||
process.exit(code || 0);
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
require('./webserver').destroy(next);
|
||||
},
|
||||
function (next) {
|
||||
winston.info('[app] Web server closed to connections.');
|
||||
require('./database').close(next);
|
||||
},
|
||||
], function (err) {
|
||||
if (err) {
|
||||
winston.error(err);
|
||||
return process.exit(code || 0);
|
||||
}
|
||||
winston.info('[app] Database connection closed.');
|
||||
winston.info('[app] Shutdown complete.');
|
||||
process.exit(code || 0);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user