关于eggjs在Linux上启动时报错的问题及解决办法

之前eggjs2.0出来以后就开始使用eggjs进行后台开发了,由于测试方便,开始时项目部署在阿里云的windows系统下面,使用npm run dev的方式进行启动

但是等到项目开发完毕后,我开始部署到生产环境的Linux系统上面,这时候问题出来了,按照eggjs

官网上面的介绍,生产环境上面的部署使用npm start的方式启动部署,但是启动一直报以下的错误

egg-scripts] Wait Start: 35...
[egg-scripts] 2018-01-23 16:12:03,863 ERROR 3941 [-/127.0.0.1/-/0ms GET /] nodejs.Error: [ClusterClient] leader does not be active in 30000ms on port:45728
[egg-scripts] at Function.waitFor (/root/egg/node_modules/_cluster-client@1.7.1@cluster-client/lib/server.js:239:15)
[egg-scripts] at waitFor.next ()
[egg-scripts] at onFulfilled (/root/egg/node_modules/_co@4.6.0@co/index.js:65:19)
[egg-scripts] at 
[egg-scripts] at process._tickCallback (internal/process/next_tick.js:160:7)
[egg-scripts]
[egg-scripts] pid: 3941
[egg-scripts] hostname: iZ2ze76p2wnibfx0j7dslmZ
[egg-scripts]
[egg-scripts] 2018-01-23 16:12:03,863 ERROR 3941 nodejs.Error: [ClusterClient] leader does not be active in 30000ms on port:45728
[egg-scripts] at Function.waitFor (/root/egg/node_modules/_cluster-client@1.7.1@cluster-client/lib/server.js:239:15)
[egg-scripts] at waitFor.next ()
[egg-scripts] at onFulfilled (/root/egg/node_modules/_co@4.6.0@co/index.js:65:19)
[egg-scripts] at 
[egg-scripts] at process._tickCallback (internal/process/next_tick.js:160:7)
[egg-scripts]
[egg-scripts] pid: 3941
[egg-scripts] hostname: iZ2ze76p2wnibfx0j7dslmZ
[egg-scripts]
[egg-scripts] 2018-01-23 16:12:03,863 ERROR 3941 [app_worker] start error, exiting with code:1
[egg-scripts] 2018-01-23 16:12:03,863 ERROR 3941 [app_worker] exit with code:1
[egg-scripts] 2018-01-23 16:12:03,869 ERROR 3925 nodejs.AppWorkerDiedError: [master] app_worker#1:3941 died (code: 1, signal: null, suicide: false, state: dead), current workers: []
[egg-scripts] at Master.onAppExit (/root/egg/node_modules/_egg-cluster@1.13.1@egg-cluster/lib/master.js:384:21)
[egg-scripts] at Master.emit (events.js:159:13)
[egg-scripts] at Messenger.sendToMaster (/root/egg/node_modules/_egg-cluster@1.13.1@egg-cluster/lib/utils/messenger.js:122:17)
[egg-scripts] at Messenger.send (/root/egg/node_modules/_egg-cluster@1.13.1@egg-cluster/lib/utils/messenger.js:87:12)
[egg-scripts] at EventEmitter.cluster.on (/root/egg/node_modules/_egg-cluster@1.13.1@egg-cluster/lib/master.js:263:22)
[egg-scripts] at EventEmitter.emit (events.js:164:20)
[egg-scripts] at ChildProcess.worker.process.once (internal/cluster/master.js:185:13)
[egg-scripts] at Object.onceWrapper (events.js:254:19)
[egg-scripts] at ChildProcess.emit (events.js:159:13)
[egg-scripts] at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
[egg-scripts] name: 'AppWorkerDiedError'
[egg-scripts] pid: 3925
[egg-scripts] hostname: iZ2ze76p2wnibfx0j7dslmZ
[egg-scripts]
[egg-scripts] 2018-01-23 16:12:03,870 ERROR 3925 [master] app_worker#1:3941 start fail, exiting with code:1
[egg-scripts] 2018-01-23 16:12:03,871 ERROR 3925 [master] exit with code:1
[egg-scripts] 2018-01-23 16:12:03,873 ERROR 3931 [agent_worker] receive disconnect event on child_process fork mode, exiting with code:110
[egg-scripts] 2018-01-23 16:12:03,873 ERROR 3931 [agent_worker] exit with code:110
[egg-scripts]
[egg-scripts] Start got error, see /root/logs/master-stderr.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! egg@1.0.0 start: egg-scripts start --workers=1 --daemon
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the egg@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-01-23T08_12_05_860Z-debug.log
 

 

 

 

被这个错误烦扰了很久,一直找不到问题所在,由于eggjs的社区还没有完善,很多问题找不到解决的方法,后面去eggjs在github的开源上提交issue,也得到了官方的答复,当时官方没有给出问题的解决办法,后面只能自己试错,通过观看代买了解到egg 通过cluster-client 来做进程间的高级通信,所以会开一些端口,但这些端口只是内部通信的,这就很尴尬了,因为我的端口只有部分开发,所以问题处在,eggjs在启动的时候,被我的防火墙给拒绝了,导致启动失败,后面尝试把防火墙的规则给清除了,然后重新运行命令npm start 启动成功了!

 

希望这个坑的经验能够帮到您

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值