2017-04-11 77 views
-1

我想创建一个nodejs集群来实例化大量'bot'实例,同时忽略任何错误。我做到了这一点,但它似乎也实例化了另一个不需要的'server.js'。我将如何做到这一点?NodeJS集群如何

server.js:https://hastebin.com/fomulopoki.js

floodmanager.js(集群):https://hastebin.com/mocaneyeso.php

错误控制台(垃圾邮件很多):

Error: bind EADDRINUSE null:3000 
    at Object.exports._errnoException (util.js:1018:11) 
    at exports._exceptionWithHostPort (util.js:1041:20) 
    at cb (net.js:1327:16) 
    at shared (cluster.js:619:5) 
    at Worker.<anonymous> (cluster.js:592:9) 
    at process.<anonymous> (cluster.js:765:8) 
    at emitTwo (events.js:111:20) 
    at process.emit (events.js:191:7) 
    at process.nextTick (internal/child_process.js:753:12) 
    at _combinedTickCallback (internal/process/next_tick.js:73:7) 
Server is up and running... 
Server is up and running... 
events.js:160 
     throw er; // Unhandled 'error' event 
    ^
+1

相关代码必须粘贴到您的实际问题中,而不仅仅在外部链接中可用。这些是stackoverflow发布规则。而且,为什么你的JS文件的扩展名是.php? – jfriend00

回答

0

你可以用PM2运行你的应用程序: http://pm2.keymetrics.io/

它有许多选项,例如在集群模式下运行您的应用程序。

你只需要在全球安装。