Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
doc: document the address object in the cluster listening event
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasMadsen authored and bnoordhuis committed Apr 28, 2012
1 parent 12a90e9 commit ab072ee
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions doc/api/cluster.markdown
Expand Up @@ -109,13 +109,19 @@ being executed.
## Event: 'listening'

* `worker` {Worker object}
* `address` {Object}

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
where the 'listening' event is emitted.

cluster.on('listening', function (worker) {
console.log("We are now connected");
The event handler is executed with two arguments, the `worker` contains the worker
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'
Expand Down Expand Up @@ -408,11 +414,12 @@ on the specified worker.
### Event: 'listening'

* `worker` {Worker object}
* `address` {Object}

Same as the `cluster.on('listening')` event, but emits only when the state change
on the specified worker.

cluster.fork().on('listening', function (worker) {
cluster.fork().on('listening', function (worker, address) {
// Worker is listening
};

Expand Down

0 comments on commit ab072ee

Please sign in to comment.