igorklopov / enclose

Compile your Node.js project into an executable
http://enclosejs.com
Other
936 stars 43 forks source link

cluster.fork #63

Closed bymaximus closed 8 years ago

bymaximus commented 9 years ago

HI, first of all, thank you for this.

Is possible to use cluster.fork with enclose? I see the forked processes start but seems they are unable to send messages to master process.

Seems i cannot use cluster.setupMaster to define 'exec' to use other js file, then im checking cluster.isMaster to execute normal flow and cluster.isWorker to require and use the worker js file.

At worker js file it have no cluster.worker object but cluster.isWorker is ok. The only event cluster master see is fork and exit.

Any tip here?

bymaximus commented 9 years ago

Ohh, just saw if I call worker.process.send(message) from master on 'fork' event, the worker receives the message,

bymaximus commented 9 years ago

Hm, I got it working by not listening worker 'online' event but 'message' event and then sending a message from forked process (process.send('online'))

cluster.fork(opts).on('online', function() {}); to cluster.fork(opts).on('message', function(msg) {});

igorklopov commented 9 years ago

Great! Anyway i will add support for fork soon

igorklopov commented 8 years ago

Enclose 2.0.0 is just released. cluster.fork is fully supported now. Please try again and post your feedback here. Consider any obstacle a bug - i will do my best to fix it.