With regards to Galaxy Rolling Restarts, can an app. hook into information about imminent restarts and affect them (delay for a bounded time)?

With regards to rolling restarts work in Galaxy, and is there any way of:

  • knowing when one is about to start (so i can choose not to start meteor methods that mutate state)
  • signalling when it is ok to take down the server (e.g.: through some “ok to shutdown” flag that I can toggle)

If not, that would be a very useful addition. MDG might bundle Galaxy specific functionality into a galaxy package.

I’m thinking of something like the following (and postulating an export called MeteorGalaxy):

var numActiveMethods = 0;
function methodStarted() {
  numActiveMethods += 1;
  // running method... please don't shutdown yet
  MeteorGalaxy.canShutdown = false;
}
function methodEnded() {
  numActiveMethods -= 1;
  if (numActiveMethods === 0) {
    // no "active methods", ready for shutdown
    MeteorGalaxy.canShutdown = true;
  }
}

Meteor.methods({
  'some-method': function someMethod(arg1, arg2, arg3) {
    if (MeteorGalaxy.shutdownImminent) {
      throw new Meteor.Error('shutdown-imminent');
      // ... or queue for action after restart and notify the client of how.........
    }
    methodStarted();
    // lots of code with yielding and all that
    methodEnded();
  }
});
1 Like

+1 Also would love an API for Galaxy (with microservices support, like the meteorhacks:cluster package but without the mongo dependency)