ServerPresence.onCleanup not always being called
heyiamben opened this issue · comments
ServerPresence.onCleanup was not always being called when meteor was killed and then restarted.
We fixed this by changing the observe function
var observe = function(){
var self = this;
observeHandle = Servers.find().observe({
removed: function(document){
if(document._id === serverId){
if(!isWatcher){
throw new Meteor.Error("Server Presence Timeout", "The server-presence package has detected inconsistent presence state. To avoid inconsistent database state your application is exiting.");
process.exit();
}else{
insert();
}
}else if(isWatcher){
if(!document.graceful){
runCleanupFunctions(document._id);
}
}else if(document.watcher){
if(!document.graceful){
runCleanupFunctions(document._id); //Cleanup here as well
}
updateWatcher();
}
}
});
};
This is great.. I had just mentioned that this was broken in an issue on socialize:user-presence the other day, but hadn't gotten around to take a look at the problem. Thanks for this.