-
-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
worker processes in cluster mode does not use the specified project file #367
Comments
Any thoughts on how you think we could solve this correctly? It'll always be an issue when forking another process to do work, so I'd love to hear your thoughts. |
//some imports
const PATH_TO_NODE = __dirname + '/../node_modules/.bin/ts-node';
cluster.setupMaster({
execArgv: [PATH_TO_NODE, '-r', 'tsconfig-paths/register'], //install tsconfig-paths before
} as cluster.ClusterSettings)
//rest of cluster.ts works except port sharing, what is the main reason for a cluster...... So it is useless. There is a EADDRINUSE error with this. Nevertheless the cluster starts and works well. I have no idea why. execArgv works, because it should give some arguments to forked node, only. Seems it starts ts-node. Looks like without that the forks are not compiled, so node is complaining about invalid "import" syntax? Just walking into dark.... |
ok, after doing some research if found out that you have to do this: //some import
cluster.setupMaster({
execArgv: ['-r', 'tsconfig-paths/register', '-r', 'ts-node/register']
} as cluster.ClusterSettings)
cluster.fork() I will create a gist tomorrow. |
To close this issue I suggest to document the need of the parameters in execArgv for clusters . It works like a charme in one of my production apps @blakeembrey |
I tested this reproduction on the latest ts-node. We set |
demo: https://github.com/gfx/ts-node-with-cluster-bugs
I found that the worker processes spawned by
cluster
module are not compiled in our environments, wheretsconfig.json
specifies"module": "es2015"
andtsconfig.universal.json
specifies"modules": "commonjs"
.This is because the worker processes always refer
tsconfig.json
which compiles *.ts for webpack, not nodejs.FYI: I have avoided this issue by creating
tsconfig.json
for nodejs andtsconfig.webpack.json
for webpack.The text was updated successfully, but these errors were encountered: