无法使用 kuberneties/docker env 在 node.js 上处理节点退出代码 0
我在 node.js 打字稿应用程序上有以下退出代码捕获器,该应用程序在 kuberneties 上用 dockerfile 包装,我试图找出为什么我的应用程序因退出代码 0 崩溃。没有任何理由
它每天发生 1-2 次,可能当有大量数据传入时,
process.on('uncaughtException', exitHandler.uncaughtException(1, 'Unexpected Error'));
process.on('unhandledRejection', exitHandler.unhandledRejection(1, 'Unhandled Promise'));
process.on('SIGTERM', exitHandler.uncaughtSignal(0, 'SIGTERM'));
process.on('SIGINT', exitHandler.uncaughtSignal(0, 'SIGINT'));
process.on('SIGFPE', exitHandler.uncaughtSignal(0, 'SIGINT'));
process.on('exit', exitHandler.uncaughtSignal(100, 'exit'));
uncaughtSignal: (code, reason) => (signal) => {
console.trace()
console.log(msg);
console.log(reason);
attemptGracefulShutdown(code); // will kill the server
},
如果我从代码中发送 process.exit(0) ,它会捕获它 但有时我不知从哪里得到了 0 号出口,
我该如何调查它?我可以添加哪个工具?
我的 docker 命令是: CMD [ "npm", "run", "start" ] (node dist/main.js)
ps aux print:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.4 334044 39116 ? Ssl Feb22 0:00 npm
root 34 0.0 0.0 16792 1288 ? S Feb22 0:00 sh -c node dist/main.js
root 35 0.0 1.0 411580 88240 ? Sl Feb22 0:41 node dist/main.js
root 51 0.0 0.0 16784 1292 pts/0 Ss 09:19 0:00 sh -c clear; (bash || ash || sh)
root 59 0.0 0.0 16784 212 pts/0 S 09:19 0:00 sh -c clear; (bash || ash || sh)
root 60 0.0 0.0 26748 3596 pts/0 S 09:19 0:00 bash
root 67 0.0 0.0 46700 3048 pts/0 R+ 09:59 0:00 ps aux
I have the following exit code catcher on node.js typescript app that wrapp with dockerfile on kuberneties , i am trying to catch why my app is crashing with exit code 0 . without any reason
its happen 1-2 times per day , probably when there are lot of data incomming
process.on('uncaughtException', exitHandler.uncaughtException(1, 'Unexpected Error'));
process.on('unhandledRejection', exitHandler.unhandledRejection(1, 'Unhandled Promise'));
process.on('SIGTERM', exitHandler.uncaughtSignal(0, 'SIGTERM'));
process.on('SIGINT', exitHandler.uncaughtSignal(0, 'SIGINT'));
process.on('SIGFPE', exitHandler.uncaughtSignal(0, 'SIGINT'));
process.on('exit', exitHandler.uncaughtSignal(100, 'exit'));
uncaughtSignal: (code, reason) => (signal) => {
console.trace()
console.log(msg);
console.log(reason);
attemptGracefulShutdown(code); // will kill the server
},
if I will send process.exit(0) from the code it will catch it
but sometime I have got exit 0 from no where ,
how can I invetigate it ? which tool can I ADD?
my docker command is : CMD [ "npm", "run", "start" ] (node dist/main.js)
ps aux print:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.4 334044 39116 ? Ssl Feb22 0:00 npm
root 34 0.0 0.0 16792 1288 ? S Feb22 0:00 sh -c node dist/main.js
root 35 0.0 1.0 411580 88240 ? Sl Feb22 0:41 node dist/main.js
root 51 0.0 0.0 16784 1292 pts/0 Ss 09:19 0:00 sh -c clear; (bash || ash || sh)
root 59 0.0 0.0 16784 212 pts/0 S 09:19 0:00 sh -c clear; (bash || ash || sh)
root 60 0.0 0.0 26748 3596 pts/0 S 09:19 0:00 bash
root 67 0.0 0.0 46700 3048 pts/0 R+ 09:59 0:00 ps aux
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论