Suppose I put a java app on Tomcat on a remote server, say Amazon AWS. What’s do you recommend to restart tomcat AUTOMATICALLY if the application fails in a unrecoverable manner?
Maybe is there a way to do this from the app itself, so that if I see that the exception is very nasty I can restart it all?
Suppose I put a java app on Tomcat on a remote server, say Amazon
Share
One possibility would be to install a watchdog which monitors (e.g. on a port, some custom check, etc.) the app and restarts entire server if necessary. This can even be a bash script which does
catalina.sh runon a controlled sub-shell.Decent monitoring systems also allow this. For example, Zabbix allows custom monitoring checks and actions so if a service is unreachable it can proactively restart it.
Another solution would be to use Tomcat manager to stop/start existing application. You can do this via Apache Ant script that invokes relevant manager URL. This solution is however not applicable if the application dies “hard” and takes the entire server down.