How can I configure Tomcat to automatically restart when get an out of memory [OOME] error.
As i think
-XX:OnOutOfMemoryError="/yourscripts/tomcat-restart"
But not sure here "yourscripts" stand for what directory?
The value you provide to -XX:OnOutOfMemoryError must be the fully qualified path to an executable (can be executable script). That script must return basically immediately so that the jvm can continue and shutdown. So it needs to attempt to stop and start tomcat in the background. This may result in effectively 2 scripts:
Script 1:
#!/bin/bash
script2.sh &
Script 2:
# stop tomcat
# make sure it is dead (kill "zombie" process if necessary)
# start tomcat
The -XX:OnOutOfMemoryError shoudl point to script 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With