Meteor Instance ID

hi,

I needed to integrate a parameter in my meteor application that allows me to clean up certain caching systems inside my application every time the meteor instance is restarted.
(my case study here: https://github.com/Keplerjs/Kepler/issues/74)

already there is a global variable in meteor that is generated uniquely for each instance?

Or should I generate a random variable in Meteor.startup ???

many tnks,
Stefano

I think that’s the way to go. Obviously, if you use multiple server instances in an application, there will be an ID for each.

1 Like

This package was designed specifically for that purpose… https://atmospherejs.com/socialize/server-presence

2 Likes

Great very interesting, can I use this? and it works with multiple instances?

ServerPresence.serverId()

Of course you can, and yes the package was designed as a way to run server specific cleanup tasks when a server goes down.

If you are doing cleanup, and don’t need the serverId for some other reason. There is the ServerPresence.onCleanup method to register a callback to run when your app exits.

1 Like