使用了定时任务的Egg项目,在服务器重启了几次就再也启动不了了。本地没毛病求指导!
发布于 9 个月前 作者 thomas0836 1572 次浏览 来自 问答

一个使用了eggjs 的项目在服务器启动时报的错,无从入手求大神指导,刚开始还是可以正常启动的,重启了几次后就变成这样了。本地使用npm run dev 启动没有毛病。 报错信息如下:

[egg-scripts] Wait Start: 23...
[egg-scripts] Wait Start: 24...
[egg-scripts] Wait Start: 25...
[egg-scripts] tail -n 100 /root/logs/master-stderr.log
[egg-scripts] Got error when startup: 
[egg-scripts] 2018-11-22 17:09:26,193 ERROR 27405 nodejs.AppWorkerDiedError: [master] app_worker#1:27557 died (code: null, signal: SIGKILL, suicide: false, state: dead), current workers: []
[egg-scripts]     at Master.onAppExit (/home/egg/u_email/node_modules/egg-cluster/lib/master.js:398:21)
[egg-scripts]     at Master.emit (events.js:182:13)
[egg-scripts]     at Messenger.sendToMaster (/home/egg/u_email/node_modules/egg-cluster/lib/utils/messenger.js:133:17)
[egg-scripts]     at Messenger.send (/home/egg/u_email/node_modules/egg-cluster/lib/utils/messenger.js:98:12)
[egg-scripts]     at EventEmitter.cluster.on (/home/egg/u_email/node_modules/egg-cluster/lib/master.js:267:22)
[egg-scripts]     at EventEmitter.emit (events.js:187:15)
[egg-scripts]     at ChildProcess.worker.process.once (internal/cluster/master.js:193:13)
[egg-scripts]     at Object.onceWrapper (events.js:273:13)
[egg-scripts]     at ChildProcess.emit (events.js:182:13)
[egg-scripts]     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
[egg-scripts] name: "AppWorkerDiedError"
[egg-scripts] pid: 27405
[egg-scripts] hostname: izwz92z9nt8wb9bvd7tv30z
[egg-scripts] 
[egg-scripts] 2018-11-22 17:09:26,194 ERROR 27405 [master] app_worker#1:27557 start fail, exiting with code:1
[egg-scripts] 2018-11-22 17:09:26,194 ERROR 27405 [master] exit with code:1
[egg-scripts] 2018-11-22 17:09:26,474 ERROR 27511 [agent_worker] receive disconnect event on child_process fork mode, exiting with code:110
[egg-scripts] 2018-11-22 17:09:26,476 ERROR 27511 [agent_worker] exit with code:110
[egg-scripts] 
[egg-scripts] Start got error, see /root/logs/master-stderr.log
[egg-scripts] Or use `--ignore-stderr` to ignore stderr at startup.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `egg-scripts start --daemon --title=u_email --env prod`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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-11-22T09_09_28_284Z-debug.log

该项目使用了定时任务。是不是这个定时任务的问题?type: 'all' 这里总是感觉怪怪的。该功能是实现一个邮件每30秒发送一次的功能。

'use strict';

module.exports = {
  schedule: {
    interval: '30s', // 1 分钟间隔
    type: 'all', // 指定所有的 worker 都需要执行
  },
  async task(ctx) {
    const { logger, service } = ctx;
    const { email } = service;
    await email.sendTask();

    logger.debug('email.sendTask working');
  },
};

2 回复

额 看看 /root/logs/master-stderr.log 有啥发现么

@Ander456

2018-11-22 17:45:45,326 ERROR 14437 [-/127.0.0.1/-/0ms GET /] nodejs.Error: [ClusterClient] leader does not be active in 60000ms on port:38980
    at Function.waitFor (/home/egg/u_email/node_modules/cluster-client/lib/server.js:238:15)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)

pid: 14437
hostname: izwz92z9nt8wb9bvd7tv30z

2018-11-22 17:45:45,327 ERROR 14437 nodejs.Error: [ClusterClient] leader does not be active in 60000ms on port:38980
    at Function.waitFor (/home/egg/u_email/node_modules/cluster-client/lib/server.js:238:15)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)

pid: 14437
hostname: izwz92z9nt8wb9bvd7tv30z

2018-11-22 17:45:45,327 ERROR 14437 [app_worker] start error, exiting with code:1
2018-11-22 17:45:45,398 ERROR 14246 nodejs.AppWorkerDiedError: [master] app_worker#1:14437 died (code: 0, signal: null, suicide: false, state: dead), current workers: []
    at Master.onAppExit (/home/egg/u_email/node_modules/egg-cluster/lib/master.js:398:21)
    at Master.emit (events.js:182:13)
    at Messenger.sendToMaster (/home/egg/u_email/node_modules/egg-cluster/lib/utils/messenger.js:133:17)
    at Messenger.send (/home/egg/u_email/node_modules/egg-cluster/lib/utils/messenger.js:98:12)
    at EventEmitter.cluster.on (/home/egg/u_email/node_modules/egg-cluster/lib/master.js:267:22)
    at EventEmitter.emit (events.js:187:15)
    at ChildProcess.worker.process.once (internal/cluster/master.js:193:13)
    at Object.onceWrapper (events.js:273:13)
    at ChildProcess.emit (events.js:182:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
name: "AppWorkerDiedError"
pid: 14246
hostname: izwz92z9nt8wb9bvd7tv30z

就是这些呢

回到顶部