Reputation: 18710
I have a Digital ocean instance, on which Tomcat7 server is running.
Sometimes it shuts itself down for reasons I don't know. That is, I launch it, work a bit with it, then do nothing with it for several days. Then I try to connect to it, but it's not available and I have to restart it (sudo service tomcat7 restart
).
I expect it to work (be available) 24/7, unless I shut it down manually. I don't see any stack traces of errors in the log files.
What may be the reason for the server to shut down after a time of inactivity?
Upvotes: 1
Views: 1563
Reputation: 13
Check your /opt/tomcat/logs/catalina.out file size. If catalina.out becomes 2GB in size, tomcat crashes and fails to start without any error message. You need to setup log rotation for catalina.out:
sudo apt-get install logrotate
Then create
/etc/logrotate.d/filename
Copy the following contents into the above file("filename")
/var/log/tomcat/catalina.out { copytruncate daily rotate 7
compress missingok size 5M }
change cron parameters as you need.
Upvotes: 0
Reputation: 41
I had this problem too, but adding swap space didn't help. In my case, tomcat was being stopped by the OOM killer. Check for this in the system logs (On Ubuntu: /var/log/syslog
): "Send sigkill to..."
For help on the OOM killer issue, you could try increasing the priority of your tomcat process:
echo -15 > /proc/PROC_NUMBER/oom_adj
(where PROC_NUMBER is your particular process). For more on tuning the OOM killer see http://www.oracle.com/technetwork/articles/servers-storage-dev/oom-killer-1911807.html
You will likely want to tune the starting and max heap sizes, the max permanent generation, and perhaps other parameters of your tomcat. You can do this through the CATALINA_OPTS environment variable, for example:
export CATALINA_OPTS="-Xms256m -Xmx384m -XX:MaxPermSize=256M"
Both of these helped me. I also have a cronjob that checks on tomcat and starts it again if necessary.
Upvotes: 1
Reputation: 18710
I asked the technical support of Digital Ocean and found out that there was no swap file in my droplet. It is a likely cause of the problem (when there is no physical memory, processes are killed because no swap file is there).
So I created it using this tutorial. I'll see whether this will solve my problem.
Upvotes: 2