-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cluster module not working? #2885
Comments
I believe the only problem is here is that It's pretty much a wanted a behavior with the cluster mode, your process is never the master so it can't run the master part. |
@vmarchaud Thanks for the info, that explains things. Now that I understand the actual "master" in the cluster is the daemon, it makes sense why there are no However, it leaves me in a bind, and I'm sure it will cause issues with some other modules too. Any module that makes decision based on For this example, I can imagine other modules would have this issue too. A brief look at Are there ways we could work around this? Some ideas:
The third option is the best for me. In that way, I can switch between using PM2 or directly with no code changes. I think it also makes the most sense and should make the above node modules work. But it probably adds a bit of work the daemon would be doing for instance management. |
You are right on the fact that all module that assume that is running in the cluster environment will fail. |
I might suggest a note in the README stating known incompatible modules or cases where other cluster-aware modules won't work. It would have saved me quite a bit of debugging time (and I would have decided to not use Known incompatible modules: |
I would totally merge a PR into our docs here to indicate this. |
What's going wrong?
As far as I can tell, when starting a PM2 app in
cluster
mode, the NodeJScluster
module is not working as expected:require("cluster").isMaster
is true butrequire("cluster").workers
is always emptyrequire("cluster").on("fork", ...)
or similar events firenode-cluster-cache
don't workHow could we reproduce this issue?
Simple repo app:
If I remove PM2 from this, and run
app.js
(usingcluster
and.fork()
on my own), everything works OK.Supporting information
The text was updated successfully, but these errors were encountered: