doc: document the address object in the cluster listening event
This commit is contained in:
parent
12a90e98bf
commit
ab072ee416
@ -109,13 +109,19 @@ being executed.
|
|||||||
## Event: 'listening'
|
## Event: 'listening'
|
||||||
|
|
||||||
* `worker` {Worker object}
|
* `worker` {Worker object}
|
||||||
|
* `address` {Object}
|
||||||
|
|
||||||
When calling `listen()` from a worker, a 'listening' event is automatically assigned
|
When calling `listen()` from a worker, a 'listening' event is automatically assigned
|
||||||
to the server instance. When the server is listening a message is send to the master
|
to the server instance. When the server is listening a message is send to the master
|
||||||
where the 'listening' event is emitted.
|
where the 'listening' event is emitted.
|
||||||
|
|
||||||
cluster.on('listening', function (worker) {
|
The event handler is executed with two arguments, the `worker` contains the worker
|
||||||
console.log("We are now connected");
|
object and the `address` object contains the following connection properties:
|
||||||
|
`address`, `port` and `addressType`. This is very useful if the worker is listening
|
||||||
|
on more than one address.
|
||||||
|
|
||||||
|
cluster.on('listening', function (worker, address) {
|
||||||
|
console.log("A worker is now connected to " + address.address + ":" + address.port);
|
||||||
});
|
});
|
||||||
|
|
||||||
## Event: 'disconnect'
|
## Event: 'disconnect'
|
||||||
@ -408,11 +414,12 @@ on the specified worker.
|
|||||||
### Event: 'listening'
|
### Event: 'listening'
|
||||||
|
|
||||||
* `worker` {Worker object}
|
* `worker` {Worker object}
|
||||||
|
* `address` {Object}
|
||||||
|
|
||||||
Same as the `cluster.on('listening')` event, but emits only when the state change
|
Same as the `cluster.on('listening')` event, but emits only when the state change
|
||||||
on the specified worker.
|
on the specified worker.
|
||||||
|
|
||||||
cluster.fork().on('listening', function (worker) {
|
cluster.fork().on('listening', function (worker, address) {
|
||||||
// Worker is listening
|
// Worker is listening
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user