Skip to content

How to pipe the output forked/cluster processes into the master stdout/stderr #1560

@IonicaBizau

Description

@IonicaBizau

When doing worker = cluster.fork() I would like to be able to forward the stdout and stderr streams into the master Node.js process.

How can I do that?

I tried doing:

worker = cluster.fork();
worker.process.stdout.pipe(process.stdout)
//             ^ this is null

A workaround would be to use messages, but I want to be able to stream content.

worker.on("message", function(msg){
  console.log("Master says:" + msg);
});
...
worker.send({message:'hello'});

How can I access the stdout of the forked process/cluster?

Stackoverflow Question

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions