isaacs / cluster-master

Take advantage of node built-in cluster module behavior
ISC License
276 stars 44 forks source link

frequently two disconnects will be required to disconnect a worker. #4

Open isaacs opened 12 years ago

isaacs commented 12 years ago

Not sure why this is. It's like the first one is being ignored.

Maybe because npm-www starts up 2 servers?

ghost commented 12 years ago

In my experience, calling .disconnect() a second time on a worker will cause it to disconnect immediately, ignoring any current ._connections open from a httpServer in that worker.

Also from what I can tell (using express / cluster) ._connections stay open on httpServer's for a long period of time (>30 seconds?) after a page request has been fulfilled, so any recently used workers won't die from a single disconnect for that long period of time.

Not sure if your two disconnects was related to the former, or your frequently was related to the latter, but wanted to share both tidbits anyways in case it's helpful.

tim-kos commented 10 years ago

I am struggling with the exact same issue.

To easily reproduce this, do the following:

master.js contains https://gist.github.com/tim-kos/0da0f2f6559646aa2076 server-worker.js (in the same directory) contains: https://gist.github.com/tim-kos/2acb5589b33403cad80b

Start master.js, go to localhost:8000 and see the server output. Then change the output around in server-worker.js from "hello world8" to "hello world9", etc. Do this as often as you want and keep refreshing your browser page. I have seen outputs from workers whose version is 3 restarts old ... and it's likely that it's related to this issue.

Here is my log output in case it's useful: https://gist.github.com/tim-kos/a2f16a644ad788512300 Please note the "Already restarting. Cannot restart yet." messages (expected) and the "Error: IPC channel is already disconnected" errors (not expected).