Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8248219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:07:11+00:00 2026-06-07T23:07:11+00:00

I have set up an automated deployment script (in shell script) for my web

  • 0

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:

  1. builds the deployable application from source repository
  2. stops tomcat
  3. applies database migration patches
  4. deploys the war files in tomcat
  5. starts tomcat (by invoking $TOMCAT_HOME/bin/startup.sh)
  6. 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? 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:07:13+00:00Added an answer on June 7, 2026 at 11:07 pm

    I ended up implementing a solution using Python’s subprocess.Popen, as suggested by @snies.

    Here’s what it looks like:

    waitForIt.py

    #! /usr/bin/env python
    import subprocess
    import sys
    
    def main(argv):
        filename = argv[1]
        match=argv[2]
        p = subprocess.Popen(['tail', '-n', '0', '-f', filename], stdout=subprocess.PIPE)
        while True :
            line = p.stdout.readline()
            print line ,
            if match in line :
                break
        p.terminate()
    
    if __name__ == "__main__":
        main(sys.argv)
    

    tailUntil.sh

    #!/bin/bash
    set -e
    
    filename=$1
    match=$2
    
    thisdir=$(dirname $0)
    python $thisdir/waitForIt.py "$filename" "$match"
    

    and then

    startTomcat.sh

    ${TOMCAT_HOME}/bin/startup.sh
    logDeploy.sh "Agora vamos dar um tail no catalina.out..."
    util_tailUntil.sh "$TOMCAT_HOME/logs/catalina.out" 'INFO: Server startup in '
    

    It doesn’t do what I originally intended (it still exits with return code 0 even when there is a stacktrace – but that could be changed with a little bit more of Python magic),
    but all of tomcat’s initialization log is part of the automated deploy out (and easily viewable on Jenkins’ deploy job) –
    so that’s good enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my web application I have set the session timeout for 30 minutes. But
I have a legacy system which uses a set of robots, (automated processes), to
I have set the eclipse java formatter to wrap lines that exceed 120 characters
I have set of flat files (114 files) each file is named with database
I have set up an app that is registered for remote notifications. - (void)application:(UIApplication*)application
I'm trying to set up the automated (nightly) installation of my web site setup
I have an automated script that generates a graph every day using GNUPlot. The
We have multiple Hudson continuous integration environments set up with automated builds and tests,
I have a Monotouch iPad application for which I am trying to set up
I have created a set of tables by executing SQL script generated by ADO.NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.