Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shutdown standalone parse server gracefully #958

Merged
merged 1 commit into from Mar 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/cli/parse-server.js
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);