Skip to content

Cluster functionality broken in nexe #638

@EricMCornelius

Description

@EricMCornelius

Is this a BUG or a FEATURE REQUEST?:
Bug

What happened:
Cluster module functionality is broken in the current version of nexe.

The primary sample from the node.js docs does not function properly:

# example taken from https://nodejs.org/api/cluster.html
> cat test.js
const cluster = require('cluster');
const http = require('http');
const numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
  console.log(`Master ${process.pid} is running`);

  // Fork workers.
  for (let i = 0; i < numCPUs; i++) {
    cluster.fork();
  }

  cluster.on('exit', (worker, code, signal) => {
    console.log(`worker ${worker.process.pid} died`);
  });
} else {
  // Workers can share any TCP connection
  // In this case it is an HTTP server
  http.createServer((req, res) => {
    res.writeHead(200);
    res.end('hello world\n');
  }).listen(8000);

  console.log(`Worker ${process.pid} started`);
}

> node test.js
Master 5133 is running
Worker 5141 started
Worker 5153 started
Worker 5160 started
Worker 5161 started
Worker 5147 started
Worker 5140 started

> nexe -t node-12.0.0-linux-x64 -o test test.js
> ./test
Master 5183 is running

What you expected to happen:
The example from the node.js docs should generate identical output for nexe bundled binary and node runtime execution

How to reproduce it (as minimally and precisely as possible):
Compare the example from the cluster api documentation between running via node and running via nexe bundled executable

Anything else we need to know?:
Lemme know :)

Environment
Dev desktop?

  • Platform(OS/Version):
    Ubuntu 18.04

  • Host Node Version:

  • Target Node Version:
    12.3.1

  • Nexe version:
    3.2.1

  • Python Version:
    2.7.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions