Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

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

Closed
hueniverse opened this issue Dec 5, 2013 · 3 comments
Closed

Comments

@hueniverse
Copy link
Contributor

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.

@latentflip
Copy link
Owner

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).

@hueniverse
Copy link
Contributor Author

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.

@bnbon
Copy link

bnbon commented Feb 12, 2015

What ever came of this? :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants