eggjs / egg

🥚 Born to build better enterprise frameworks and apps with Node.js & Koa
https://eggjs.org
MIT License
18.87k stars 1.81k forks source link

egg.js怎么在捕获到异常的情况下重启egg服务 #1983

Closed nlove518 closed 6 years ago

nlove518 commented 6 years ago

在中间件捕获异常后,怎么通过代码重启egg服务?启动egg服务的代码怎么写?

atian25 commented 6 years ago

捕获异常后为啥要重启?

nlove518 commented 6 years ago

@atian25 因为之前遇到timeout的问题 重启之后服务才能恢复正常。 所以想通过捕获timeout 错误,让服务重启。

atian25 commented 6 years ago

关键还是那个问题,为啥 timeout 了,看那边的 issue,貌似官方也没法复现?

想重启就 process.exit() 杀掉自己。