Currently, the only way to see if my Tomcat has fully started up is to check apache-tomcat log:
tail -f ./catalina.out
and look for this pattern to show up before I do any job.
org.apache.catalina.startup.Catalina.start Server startup in [0-9]* ms
I wanted to automate the process and wrote the script below, which did work.
tail -f ./catalina.out | egrep -q '*.Catalina.start Server startup in [0-9]* ms$'
touch done
But the problem is that it sometimes reads the previous Startup and finishes right off.
The desired process:
Tomcat stops -> Tomcat restarts -> The tail shell runs -> Tomcat full starts up -> The shell tells me it's done
What my script might do:
Tomcat stops -> Tomcat restarts -> The tail shell runs -> It immediately tells me Tomcat is fully booted because of the previous log.
How do I achieve this?
tail
buffers output, whilegrep
(without--line-buffered
) waits for a buffer full of lines. Use tools likepgrep
andlsof
to catch the startup.