Merge pull request #958 from raulr/graceful-shutdown

Shutdown standalone parse server gracefully
This commit is contained in:
Drew
2016-03-10 12:35:55 -08:00

View File

@@ -65,7 +65,7 @@ const app = express();
const api = new ParseServer(options);
app.use(options.mountPath, api);
app.listen(options.port, function() {
var server = app.listen(options.port, function() {
for (let key in options) {
let value = options[key];
@@ -77,3 +77,12 @@ app.listen(options.port, function() {
console.log('');
console.log('parse-server running on '+options.serverURL);
});
var handleShutdown = function() {
console.log('Termination signal received. Shutting down.');
server.close(function () {
process.exit(0);
});
};
process.on('SIGTERM', handleShutdown);
process.on('SIGINT', handleShutdown);