nodejs coffee cluster process execPath
今天做项目coffee启动的时候,如下报错:

调试发现是因为模块中用了cluster,去掉cluster一切正常。
猜想主进程应该是没有问题的,那么报错出在fork出来的进程中。
从网上获知:
cluster.fork calls child_process.fork on the running module. child_process.fork runs the module with process.execPath which is coming out to /usr/bin/node. In other words, cluster is trying to run the workers with node, and it's expecting a JavaScript file, not a CoffeeScript file.
这样就明确了,fork出来的process.execPath默认是/bin/node。
那么只需要在模块中添加process.execPath = 'coffee'
即可解决。
参考:
https://github.com/jashkenas/coffee-script/issues/2737
posted on 2013-11-29 15:28 magic.xiao 阅读(1374) 评论(0) 收藏 举报
浙公网安备 33010602011771号