Skip to content

Commit

Permalink
Merge pull request #958 from raulr/graceful-shutdown
Browse files Browse the repository at this point in the history
Shutdown standalone parse server gracefully
  • Loading branch information
drew-gross committed Mar 10, 2016
2 parents 2300b21 + 76e6f8c commit 2114153
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/cli/parse-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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);

0 comments on commit 2114153

Please sign in to comment.