Understanding the Worker Object

When a worker process is forked, a new Worker object is created in both the master and worker processes. In the worker process, the Worker object is used to represent the current worker and interact with cluster events that are occurring. In the master process, the Worker object is used to represent child worker processes so that your master application can send messages to them, receive events on their state changes, and even kill them.

Table 9.12 lists the events that Worker objects can emit.

Image

Table 9.12 Events that can be emitted by Worker objects

Table 9.13 lists the methods and properties you can use with Worker objects to get information such as whether the node is a worker or the master as well as to configure and implement the forked processes.

Image

Table 9.13 Methods and properties of Worker objects

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset