latentflip/hapi_primus_sessions

Plugin won't work if more than one server in a process loads it

hueniverse opened this issue · 3 comments

Plugins should not use any singleton module objects. Instead, the register() method should create a new instance of the "globals" you need and pass that to the routes or other methods defined.

I'll definitely add a caveat to the readme for this in the short term. I think for most use-cases only a single server would want to load this plugin anyway - i.e. the one that handles the main sessions that you want in primus. I think trying to make that work with multiple servers would make it very complicated.

(I'm still getting to grips with hapi so I may well be wrong on that).

You just need to move all your module globals into a prototype and then new that object inside register. Pretty simple. We do this in every other plugin.

What ever came of this? :)