Problems with the cluster module and node's eval

35 views
Skip to first unread message

Adam Snodgrass

unread,
Oct 1, 2014, 12:55:12 AM10/1/14
to nod...@googlegroups.com
I'm currently working on a project that requires compiling the source into node.js (0.10.32). After moving all the source files into `lib/`,referencing them in node.gyp and some other work, I add `process._eval = 'require("app");';` to `src/node.js`. This works fine but if I try using the cluster module, it causes problems. 

I found that I could remove the `process._eval` line and move the cluster setup code to a separate external file that requires the app module and execute it with node it works fine. So I was able to narrow the issue down to the eval option by testing the following:


I was curious what `worker` was assigned to so I modified the `lib/cluster.js`  file to `console.log(worker);` and it was `{}`, which explains the missing method. I'd like to investigate this further but I'm hoping someone else has run into this issue previously.


Adam Snodgrass

unread,
Oct 1, 2014, 2:07:07 AM10/1/14
to nod...@googlegroups.com
Instead of messing with process._eval I decided to find where node starts the main code. Turns out things work fine if you add the clustering code in `lib/module.js`'s runMain function. 
Reply all
Reply to author
Forward
0 new messages