-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Conversation
…ster, added options argument; HandleWorkerMessage: emit events, echo allwas queryID if required, added listening command; fork: give each worker a protected workerID; queryMaster: made public, renamed to worker.send; _getServer: send a listening command to master.
I'm in the process of writing the documentation. |
I finished documenting the changes i have made.
This changes has not yet been made in the cluster.js native module. |
I has added @visionmedia commit 58b558a to this pull request. |
I am considering to make the Worker class useful to both master and worker. In that way the API will almost be the same for the master and worker. In master
This is all ready done. In worker
|
I noticed that my commits don't fit the |
I have updated the pull request so both the worker and master are using the Worker class. I do not have any more plans for changes, but i would like to discuss:
Update |
Really liking the look of these changes :-) Wondering if it will be possible to set the exec option per worker that's spawned. I have a server that behaves differently depending on command line options. I'd like to be able to exercise these different behaviours from a single set of tests. I could use child_process.fork to run the server multiple times, but maybe it would be more convenient to be able to run workers that do different jobs from the same master? Thanks Tom |
@tomyan sure this is possible :) Please note: This module is not made for easy testing. And too have different workers running do not mak much sense, since there is no way to know how the OS will balance this and then clients will be treaded differently :/ Can you not use the I'm open to suggestion but I do not see the purpose of this yet. |
…especially in case of a cirtical error
There was some errors related to when there is a critical error in the worker and |
That was a difficult merge! |
Closing this. Everything has been split up into separate reqs. |
In 0.6.x the cluster module was just a small extension on the
node_process.fork()
function. The propose of this pull request is to make the cluster module easier to setup, without removing the basic functionality. It also add a lot of new functionality there make it possible for userland plugins to interact with the cluster module.Documentation:
The documentation can be found here.
This request fix the following issues:
This request contain the following changes:
.eachWorker(fn)
method..setupMaster()
.fork([env])
message
eventworker.destroy()
child_process.fork
tocluster.fork().process
.new Worker()
object..disconnect()
method to make a gracefully shutdownfork
,listening
,disconnect
SIGTERM
,SIGINT
andSIGQUIT
on a workercluster.workerOnline
property to get how many workers there are onlineSIGTERM
,SIGINT
,SIGQUIT
andSIGCHLD
on master.cluster.disconnect()
method.cluster.destroy()
method.cluster.isWorker
andcluster.isMaster
is now protectedworkerID
, it's a number there will be reused when the worker spawn/respawn.uniqueID
, if is a unique number there will change for each spawn/respawn..autoFork()
and manual.fork()
.citicalError
event when a respawn infinite loops is detected.startup
property to worker object.silent
option to the setupMaster to prevent output from workers to be showen in the master as outout.SIGHUP
signal the cluster will restart graceful.settings
object to the clustersetup
to cluster, this will emit whensetupMaster
execute.destroy
notkill
kill
is changed todeath
This changes was made in other modules:
silent
option, thechild_process.fork()
has been updated to takesilent
as a option in theoptions
argument. This is a very small change.This changes will be included in the near future: