java - java process finishes after some time with no particular reason
问题描述
I have a java .jar file that i launch on an AWS instance in detached mode. So when i exit the ssh session, it still runs.
The app does some network stuff, and is expected to run for days until it finishes it task.
I have made logs all over the app, made log in the end of main method. I also made a global try/catch and added logging to the catch section.
Still, after some days i enter into ssh and see that the app just stopped running. No exceptions, main method did not complete because the log in the end did not trigger. It seems that the process was just killed in the middle of working. Sometimes it works for 5 hours, sometimes for 3-4 days without stopping.
I have no idea what could be the cause of this. I expect the java process to run until it finished, or until it crashes. Am i missing something?
upd: it is an aws t2.micro, i think, the free tier one. It runs ubuntu 18.04.3 LTS
解决方案
您需要监视服务器和应用程序。首先要查看的是任何 CPU 或内存峰值的实例 cloudwatch 统计信息。如果你找到了,你就知道如果你想在微实例上运行你的应用程序需要修复什么。进一步阅读
或者,您可以在运行应用程序时定期收集和转储 Java 进程统计信息。这可以深入了解堆、堆栈和 cpu 的使用情况。检查此 SO 帖子以获取更多详细信息:
推荐阅读
- excel - .Hidden 属性的意外行为
- python - 如何修改特定 dask 数据框分区的值?
- python - Extracting statistics/information from images
- c# - C# MVC:操作可能会破坏运行时的稳定性
- python - 计划任务执行中的芹菜错误
- sockets - ICMP RAW Socket 接收不完整
- automation - 编码的 ui 对象存储库
- mysql - 表被锁定在 MySQL 数据库中
- mongodb - Mongodb 3.4.7 分组后一个字段的聚合不同计数
- c# - C# 检查 PropertyInfo 的类型是否是原始的