Skip to content

Cluster: worker.disconnect waits for handles to close before firing "disconnect" event #4542

Closed
@cjthompson

Description

@cjthompson

In the classic (0.10) cluster scheduler (SCHED_NONE), when worker.disconnect() is called, the worker immediately emits a "disconnect" event, then proceeds to wait for exiting connections to close before terminating the child process:

Worker.prototype.disconnect = function() {

In the Round Robin mode, worker.disconnect() does not fire a disconnect event, and it waits for all the handles to close before disconnecting the child process.

Worker.prototype.disconnect = function() {

In short, the old behavior was to: 1) fire "disconnect", 2) wait for handles to close, 3) fire "exit". The new behavior is 1) disconnect IPC (but don't fire "disconnect" event), 2) wait for handles to close, 3) fire "disconnect" event, 4) fire "exit" event

The scenario I'm looking at is if a worker disconnects, I'd like the master to immediately start a new worker in its place, while waiting for the previous worker to terminate (or force terminate it if it takes too long to close on its own).

This was possible with the old scheduler, but not the round robin scheduler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clusterIssues and PRs related to the cluster subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions