0

I'm using CentOS 7 and Tomcat 8 to serve an online shop. After logging into the server via SSH, I usually run ./startup.sh and everything works smoothly, except for one thing:

From time to time Tomcat shuts down, which, of course, results in the online shop not being available until I run ./startup.sh again (manually).

Do you have any suggestions how to prevent Tomcat from shutting down?

Is it a good idea to write a script that checks the connection (via cURL, for example) and in case of error executs ./startup.sh?

  • monit is sometimes used for this (available in the EPEL repository). – Brian Jan 7 '15 at 3:08
  • 1
    Why don't you just write a systemd unit for it? systemd can restart it automatically and you don't need any third party stuff. – Michael Hampton Jan 7 '15 at 3:23
0

Is it a good idea to write a script that checks the connection (via cURL, for example) and in case of error executs ./startup.sh?

Of course it is a good idea! Of course it's a bad idea!

Why is it a bad idea: you're not fixing the problem. You're just fixing the symptoms. But it's a good idea while you are debugging because having your online shop actually on-line is more important on the immediate basis.

If I was in your shoes, I would do this:

  1. Set up a mechanism so that Tomcat is restarted automatically. Monit is a good option for this. Don't ask me how to set it up as I don't use it personally.

  2. Then you need to have monitoring. You need to know your site is up. And you need to know when it is down. Even if you have an automated procedure to restart Tomcat, if you don't know that Tomcat is restarting, then you would be like a ostrich (head in the sand not wanting to see the danger). Many on-line services can provide you notification for free or cheap, if you don't have an in-house monitoring solution.

  3. You need to start looking. You need to get to the bottom of this. Tomcat doesn't just vanish for no good reason. The application it is running is causing some issues or you have some corruption on your OS, run out of memory. Something. If it truly vanishes, you're most-likely going to have a dump file giving you the data as to what is happening. Usually the dump files are in the same directory as your binaries.

  4. Actually resolve the cause of the problem. See the 5 Whys approach for example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.