I have set up an automated deployment script (in shell script) for my web application.
It uses java, tomcat, maven and a postgres database.
The deployment script does this:
- builds the deployable application from source repository
- stops tomcat
- applies database migration patches
- deploys the war files in tomcat
- starts tomcat (by invoking $TOMCAT_HOME/bin/startup.sh)
- exits with a success message
It's all working and it's pretty neat - but it needs a little improvement. You see, even though it exits with a success message, sometimes the deploy was not successful because the web application did not start correctly.
I would like to refactor steps 5 and 6 so that after bring up the tomcat server, the deployment script would "tail -f" in the catalina.out file, looking either for a "server started successfully" message or an exception stack trace.
The tail -f output up to that point should be part of the output of the deployment script, and step 6 would "exit 0" or "exit 1" accordingly.
I know that should be possible, if not in shell script, maybe with python. The problem is I'm a java specialist - and by specialist I mean I suck at everything else :-)
Help please? :-)