Hoàng Long
Hoàng Long

Reputation: 10848

Auto-detect tomcat failed start by bash scripts

I wrote a bash script to auto-deploy a web-application to tomcat container whenever it is triggered. It is pretty straight-forward:

  1. Dump the current database for back-up
  2. Shutdown the current tomcat process
  3. Delete the web-application folder
  4. Replace the war file with the new one
  5. Start tomcat again

However, now I want to have a fall-back. If there's some problem in start-up process, the database will get restored and the old war file is deployed again.

My problem is that I don't know when a web-application failed to start. One of my implementation is that I will check the size of the logging file of my web application, if after a while it doesn't increase (which means there's nothing get written), then the system should understand that deployment is failed and we should restore the old web-application. However, this is kind of dirty and I'm not sure what will happen if my logging file get rolled right at that time.

Does tomcat has any mechanism to support start-failed detection of a web-application?

Upvotes: 2

Views: 487

Answers (1)

seedhead
seedhead

Reputation: 3805

Have you looked at the Manager that ships with Tomcat? It gives you an API to easily determine the status of web apps deployed inside it.

Upvotes: 1

Related Questions