immediately shutdown if home server is stopped

This commit is contained in:
Stephen Birarda 2016-01-18 11:31:49 -08:00
parent 21074fe4e4
commit 7186a538b2

View file

@ -87,15 +87,22 @@ function shutdown() {
homeServer.stop();
}
var timeoutID = setTimeout(app.quit, 5000);
homeServer.on('state-update', function(processGroup) {
if (processGroup.state == ProcessGroupStates.STOPPED) {
clearTimeout(timeoutID);
app.quit();
}
});
updateTrayMenu(null);
if (homeServer.state == ProcessGroupStates.STOPPED) {
// if the home server is already down, take down the server console now
app.quit();
} else {
// if the home server is still running, wait until we get a state change or timeout
// before quitting the app
var timeoutID = setTimeout(app.quit, 5000);
homeServer.on('state-update', function(processGroup) {
if (processGroup.state == ProcessGroupStates.STOPPED) {
clearTimeout(timeoutID);
app.quit();
}
});
}
}
}
}