[#142] Make sure Tomcat stops completely in Docker containers before restarting it

This commit is contained in:
apldev3 2019-05-20 17:16:24 -04:00 committed by apldev4
parent 59ad180688
commit 77d48631f4
2 changed files with 6 additions and 2 deletions

View File

@ -75,6 +75,10 @@ if [ $DOCKER_CONTAINER = true ]; then
if [[ $(ss -t -l -n | grep -q LISTEN.*:::8009) -eq 0 ]]; then if [[ $(ss -t -l -n | grep -q LISTEN.*:::8009) -eq 0 ]]; then
echo "Tomcat is running, so we restart it." echo "Tomcat is running, so we restart it."
/usr/libexec/tomcat/server stop /usr/libexec/tomcat/server stop
# Wait for Tomcat to stop completely and prevent port bind collisions
while [ -z $(tail -n 1 /var/log/tomcat/catalina.$(date +"%Y-%m-%d").log | grep "Destroying ProtocolHandler \[\"http-bio-8443\"\]") ]; do
:
done
(/usr/libexec/tomcat/server start) & (/usr/libexec/tomcat/server start) &
# Wait for Tomcat to boot completely # Wait for Tomcat to boot completely
until [ "`curl --silent --connect-timeout 1 -I http://localhost:8080 | grep 'Coyote'`" != "" ]; do until [ "`curl --silent --connect-timeout 1 -I http://localhost:8080 | grep 'Coyote'`" != "" ]; do