In the child the `process` object will have a `send()` method, and `process`
will emit objects each time it receives a message on its channel.
-There is a special case when seinding a `{cmd: 'NODE_foo'}` message. All messages
-containging a `NODE_` prefix in its `cmd` property will not be emitted in
-the `message` event, since this are internal messages used by node core.
-Messages contain the prefix are emitted in the `internalMessage` event, you
+There is a special case when sending a `{cmd: 'NODE_foo'}` message. All messages
+containing a `NODE_` prefix in its `cmd` property will not be emitted in
+the `message` event, since they are internal messages used by node core.
+Messages containing the prefix are emitted in the `internalMessage` event, you
should by all means avoid using this feature, it may change without warranty.
By default the spawned Node process will have the stdout, stderr associated
### cluster.workers
In the cluster all living worker objects are stored in this object by there
-`uniqueID` as the key. This makes it easy to loop thouge all liveing workers.
+`uniqueID` as the key. This makes it easy to loop through all living workers.
- // Go througe all workers
+ // Go through all workers
function eachWorker(callback) {
for (var uniqueID in cluster.workers) {
callback(cluster.workers[uniqueID]);
worker.send('big announcement to all workers');
});
-Should you wich to reference a worker over a communication channel this unsing
-there `uniqueID` this is also the easies way to find the worker.
+Should you wish to reference a worker over a communication channel, using
+the worker's uniqueID is the easiest way to find the worker.
socket.on('data', function (uniqueID) {
var worker = cluster.workers[uniqueID];
## Worker
This object contains all public information and method about a worker.
-In the master it can be obtainedusing `cluster.workers`. In a worker
-it can be obtained ained using `cluster.worker`.
+In the master it can be obtained using `cluster.workers`. In a worker
+it can be obtained using `cluster.worker`.
### Worker.uniqueID
-Each new worker is given its own unique id, this id i stored in the `uniqueID`.
+Each new worker is given its own unique id, this id is stored in the `uniqueID`.
### Worker.process
### Worker.destroy()
This function will kill the worker, and inform the master to not spawn a new worker.
-To know the difference between suicide and accidently death a suicide boolean is set to true.
+To know the difference between suicide and accidentally death a suicide boolean is set to true.
cluster.on('death', function (worker) {
if (worker.suicide === true) {
}
// Check if a message is internal only
-var INTERNAL_PREFIX = 'NODE_CLUTER_';
+var INTERNAL_PREFIX = 'NODE_CLUSTER_';
function isInternalMessage(message) {
return (isObject(message) &&
typeof message.cmd === 'string' &&
message._queryEcho = inMessage._requestEcho;
// Call callback if a query echo is received
- if (inMessage.hasOwnProperty('_queryEcho')) {
+ if (inMessage._queryEcho) {
queryCallbacks[inMessage._queryEcho](inMessage.content, inHandle);
delete queryCallbacks[inMessage._queryEcho];
}