doxout/recluster

Multiple calls support

7nights opened this issue · 6 comments

In a project I need to call recluster 2 times because there are 2 separate servers. After calling recluster 2 times I found the first call's workers can't respawn correctly because the exec file was changed by the second call. I find it's easy to allow this to be happen( see 7nights@909f71d ). Can this feature be supported?

AFAIK this is not supported by the core cluster library, which is what recluster is based on.

Might I suggest that you run 2 separate processes for 2 servers?

Hi @spion, may I ask why it is not supported by the core cluster library? Or I missed something? Because it's possible to call setupMaster() multiple times(nodejs/node-v0.x-archive#7671, also nodejs/node-v0.x-archive#3367), I thought this could be achieved... XD

As long as the cluster module is a global singleton object, this wont be achievable.

Do you really need to run multiple servers from one process?

Nope but it will make things a bit more complicated. In my environment I can only run servers through a single js file which is executed every single time I commit the code. If it's not possible to call recluster multiple times, I need to do some work to manage these processes. I just used my edited version to replace the original one and find that it works fine. So I'm wondering if there's something I missed and I should stop doing this?

As far as I can see 3367 hasn't been merged yet, and 7671 only lets you call setupMaster on the same cluster singleton multiple times.

Looking at your fork, it seems like you call setupMaster every time you spawn a worker. That does seem a bit dangerous to me - I'm not even sure if it will work correctly?

In your situation I would write a third file that spawns the two recluster servers as normal processes.

note: We use https://github.com/spion/nac but unfortunately it doesn't expose a library interface so it can't run in your environment

spion commented

Closed as it seems this is still out of reach because built in cluster cant support it. Ping me if I'm totally wrong.