Code Monkey home page Code Monkey logo

Comments (13)

andrewshawcare avatar andrewshawcare commented on June 22, 2024 23

Yeah, I did that but that approach is potentially misleading.

For example:

./wait-for-it.sh service-a:1234 -- ./wait-for-it.sh service-b:1234 -- docker-entrypoint.sh

Logically, is service-b dependent on service-a? In my case it isn't (so they shouldn't be chained). In my view, it would be clearer to have:

./wait-for-it.sh service-a:1234 service-b:1234 -- docker-entrypoint.sh

Structurally, there should be two options:

container -> {service-a, service-b} // set denotes mutually-exclusive dependencies
container -> [service-a, service-b] // list denotes dependency order

A chain provides a list mechanism and multiple host:port arguments provides a set mechanism.

from wait-for-it.

jlordiales avatar jlordiales commented on June 22, 2024 16

@andrewshawcare FWIW I implemented this on https://github.com/jlordiales/wait-for-it/blob/master/wait-for-it.sh (for my use case at least). You can specify multiple host:port pairs and the whole thing will fail as soon as the first host times out

from wait-for-it.

vishnubob avatar vishnubob commented on June 22, 2024 3

I feel like this is better solved by either a top level script that orchestrates the logic of such a situation or chaining multiple wait-for-it commands together.

from wait-for-it.

Forever-Young avatar Forever-Young commented on June 22, 2024 1

Didn't see this issue, also implemented this: Forever-Young@f9aa0c1

from wait-for-it.

clarketm avatar clarketm commented on June 22, 2024 1

There is a python version of wait-for-it that supports waiting for multiple services. It is blocking and will wait for the services to be available in sequential order.

e.g.

Assuming both python3 and wait-for-it are installed.

$ wait-for-it \
--service www.google.com:80 \
--service www.bing.com:80 \
--service www.duckduckgo.com:80 \
-- echo "google, bing, and duckduckgo are up (in that order)"

Here are the docs!

from wait-for-it.

Feche-314 avatar Feche-314 commented on June 22, 2024 1

There is also a shell script called docker-compose-wait which allows this required behaviour:

version: "3"

services:
  mongo:
    image: mongo:3.4
    hostname: mongo
    ports:
      - "27017:27017"

  postgres:
    image: "postgres:9.4"
    hostname: postgres
    ports:
      - "5432:5432"

  mysql:
    image: "mysql:5.7"
    hostname: mysql
    ports:
      - "3306:3306"

  mySuperApp:
    image: "mySuperApp:latest"
    hostname: mySuperApp
    environment:
      WAIT_HOSTS: postgres:5432, mysql:3306, mongo:27017

from wait-for-it.

vishnubob avatar vishnubob commented on June 22, 2024

A high-level script is your best option to solving this particular use case, as it allows you the flexibility you need in testing and interpreting the various states that arise in your specific scenario. wait-for-it is intentionally designed to keep-it-simple, leaving the use-case you describe as an exercise for the reader. Feel free to fork and tailor to your needs.

from wait-for-it.

jlordiales avatar jlordiales commented on June 22, 2024

@vishnubob did you get to implement your use case? I was looking to do exactly the same

from wait-for-it.

vishnubob avatar vishnubob commented on June 22, 2024

@jlordiales: i think you meant to ask @andrewshawcare, since he originally posted the issue.

from wait-for-it.

jlordiales avatar jlordiales commented on June 22, 2024

Yes @vishnubob, sorry it was late :)

from wait-for-it.

frastel avatar frastel commented on June 22, 2024

Could this issue be closed as "won't fix" so it is clear that this high-level functionality shouldn't be integrated in this project?
As vishnubob already mentioned it makes totally sense to keep this script as simple as possible and to not patch this script for this reason.

from wait-for-it.

Forever-Young avatar Forever-Young commented on June 22, 2024

I guess it's enough to have some receipts just in the issue comments.

from wait-for-it.

codan84 avatar codan84 commented on June 22, 2024

There is also a shell script called docker-compose-wait which allows this required behaviour:

version: "3"

services:
  mongo:
    image: mongo:3.4
    hostname: mongo
    ports:
      - "27017:27017"

  postgres:
    image: "postgres:9.4"
    hostname: postgres
    ports:
      - "5432:5432"

  mysql:
    image: "mysql:5.7"
    hostname: mysql
    ports:
      - "3306:3306"

  mySuperApp:
    image: "mySuperApp:latest"
    hostname: mySuperApp
    environment:
      WAIT_HOSTS: postgres:5432, mysql:3306, mongo:27017

Thanks for this tip, much better imo and not dependant on bash present in the image

from wait-for-it.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.