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 6766121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:47:33+00:00 2026-05-26T14:47:33+00:00

We do our deployments with capistrano. Our website consists of a rails frontend and

  • 0

We do our deployments with capistrano. Our website consists of a rails frontend and java API backend.

I have a situation where the java API application takes about 15 minutes to start up and the rails application can’t run without it. Initially I tried to loop within capistrano using the capture command to wait until the application started listening on the port (8080 in our case):

desc "Start api"
task :api, :roles => :api do
  run("cd #{home_api} && ./api.sh start > /dev/null 2>&1 &")
  sleep 1
  api_status = nil
  until api_status
    api_status = capture("echo `netstat -tln | grep 8080`")
    sleep 60
  end
  puts "API Started successfully."
end

However, capture only runs on one server (we have several API machines) and if that one finishes starting up before the others the deployment may proceed before all the API machines are ready.

I need something that will wait for a port to be open on all servers matching the specified role before moving on.

  • 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-05-26T14:47:34+00:00Added an answer on May 26, 2026 at 2:47 pm

    Here’s how I am currently doing this:

    Using ‘run’ to execute some shell commands that won’t return until the port is open (or until 30 minutes have passed in this case.) This will run on all the matching servers and won’t continue until all of them have completed.

    desc "Start api"
    task :api, :roles => :api do
      run("cd #{home_api} && ./api.sh start > /dev/null 2>&1 &")
      sleep 1
      run("for i in {0..60}; do echo \"Waiting for API to start\"; if [[ \"\" != \"$\(netstat -an |grep 8080\)\" ]]; then break; fi; sleep 30; done")
    end
    

    I’m curious to see how other people are doing this, there surely is a better way?

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

Sidebar

Related Questions

I have a directory where our deployments go. A deployment (which is itself a
We deployed our legacy ASP.NET application to production after successful test deployments to our
I have an idea to streamline deployments of prototypes within our team using VMs.
I have been tasked with looking into our deployments, and seeing where they can
For our web development, we have daily to weekly deployments. There are instances where
I am switching our application for Capistrano deployment to Gradle . Here requirement to
I've been assigned the task of making our Java web application work with Oracle
I'm trying to setup Capistrano to do our deployments, but I now stumbled upon
For our deployments, I just want to drop the existing stored proc, then re-create
I am having some trouble trying to adjust the deployment settings of our application

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.