服務直接被 killed,感覺特別奇怪。代碼肯定是沒有問題的,但為什么放到服務器上就出錯了呢。
部署時報錯如下:
- Failed to add the deployment content to the repository: java.util.concurrent.CancellationException: Operation was cancelled
wildfly 報錯如下:
- ./standalone.sh: line 307: 12526 Killed
一時還真看不出是什么毛病。
於是使用 dmesg 查找原因,終於找到了原因:
- # dmesg | tail
- [1147898.706546] Out of memory: Kill process 12526 (java) score 399 or sacrifice child
- [1147898.710393] Killed process 12526 (java) total-vm:2559448kB, anon-rss:403304kB, file-rss:780kB, shmem-rss:0kB
- [1147898.738479] oom_reaper: reaped process 12526 (java), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
原來是因為內存不足導致了。我使用的服務器內存只有 1G,上面跑了很多的服務,因此可以內存並不大,所以才出了問題。