I have tomcat server running. and it crashes suddenly for some reason... however I am trying to find the error.
Is there a function in tomcat or java like beforeExit()
or ifCrashed()
which I can override and write some code there like notifying myself if server crashes for some reason.
You could try using shut down hooks which are executed on system exit. It's not guaranteed though that it will be executed on a hard crash like SIGKILL but this may be an option in some cases:
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
// Implementation goes here..;
}
});
I don't think that crashed server can manage something. You can consider this steps:
servletContextListeners
in order to run code before servlet context will shutdown. It will work if shutdown is done gracefullyOutOfMemoryError
and open JMX ports for monitoringHTTPStatus.OK
then it working, if not - then you can report yourself someway.It could be better if you can provide logs and some information about what is really happening with server. Maybe here people will help but I gues this is topic of another questions.
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