wait-for-it | Pure bash script to test and wait on the availability | TCP library
kandi X-RAY | wait-for-it Summary
kandi X-RAY | wait-for-it Summary
Pure bash script to test and wait on the availability of a TCP host and port
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of wait-for-it
wait-for-it Key Features
wait-for-it Examples and Code Snippets
$ wait-for-it \
--service www.google.com:80 \
-- echo "google is up"
[*] Waiting 15 seconds for www.google.com:80
[+] www.google.com:80 is available after 0 seconds
google is up
$ wait-for-it \
--service www.google.com:80 \
--timeout 0 \
-- echo "g
public interface Callback {
void call();
}
public abstract class Task {
final void executeWith(Callback callback) {
execute();
Optional.ofNullable(callback).ifPresent(Callback::call);
}
public abstract void execute();
}
@Slf4j
p
Usage: wait-for-it [OPTIONS] [COMMANDS]...
Wait for service(s) to be available before executing a command.
Options:
-h, --help Show this message and exit.
-v, --version Show the version and exit.
-q, --quiet
public synchronized void incrementWithWait() throws InterruptedException {
int temp = count;
wait(100);
count = temp + 1;
}
Community Discussions
Trending Discussions on wait-for-it
QUESTION
Say I'm executing a file named run.sh
. I have this commands inside this file:
ANSWER
Answered 2022-Mar-24 at 17:33From the wait-for-it website that you linked:
QUESTION
I have a NodeJS Express App that depends on MongoDB change streams. For them to be available, MongoDB has to be configured to run as a replica set (even if there is only one node in that set).
I'm working on Windows 10 pro.
I'm trying to dockerize this App, basing the MongoDB container off the official mongo:5
image.
For this to work, I want an automated way of initializing the DB as a replica set. Tutorials I've found rely on either exec
ing into the container and running rs.initiate()
from mongosh
(or similar approaches), which is manual work I want to avoid. Or they use hacks like wait-for-it.sh
as here.
I feel there must be a better solution, based somehow on the paragraph "Initializing a fresh instance", from the docs.
It describes that
When a container is started for the first time it will execute files with extensions
.sh
and.js
that are found in/docker-entrypoint-initdb.d
.
When exactly in the container lifecycle does that happen? After the container is initialized? Or after the DB is ready? Because this seems to be the perfect place for this initialization logic, which runs flawlessly when executed manually, from within the container.
However, placing
...ANSWER
Answered 2022-Feb-16 at 08:14I just made it work with a wild experiment. Means I simply left out the config in my call to rs.initiate()
, from the JS script. For some reason, the script then runs successfully and change streams become available to my NodeJS backend.
I will post everything that's needed to run a MongoDB docker with change streams enabled:
QUESTION
I want to connect my Spring Boot container with my database container. I can connect with a db app like db beaver.
Here is my setup:
docker-compose.yml
...ANSWER
Answered 2022-Feb-13 at 19:59Try adding a network and environments so that containers can communicate,
QUESTION
I'm looking for an up-to-date example of how to get PuppeteerSharp running on an AWS Elastic Beanstalk instance running Docker (.NET Core 6). There are quite a few articles out there which are either outdated, poorly documented, or both. I tried installing Chrome dependencies in my Dockerfile, however, I'm not able to get it running.
Does anyone have a working example using AWS + .NET Core 6 + Docker + Puppeteer?
This is my current Dockerfile:
...ANSWER
Answered 2022-Jan-25 at 09:17I worked it out myself. See this GitHub issue for details.
QUESTION
I am trying to docker-compose up
my containers, one for backend and another one for the database (postgis). If I docker-compose up db
, I see db_1 | 2021-11-23 10:36:02.123 UTC [1] LOG: database system is ready to accept connections
, so, it works.
But if I docker-compose up
the whole project, I get
ANSWER
Answered 2021-Nov-26 at 11:11My problem was: if I healthcheck
my db container,
I also should not forget to add a condition to my depends_on
like this:
QUESTION
The documentation for depends_on states:
There are several things to be aware of when using
depends_on
:
depends_on
does not wait fordb
andredis
to be “ready” before startingweb
- only until they have been started. If you need to wait for a service to be ready, see Controlling startup order for more on this problem and strategies for solving it.The
depends_on
option is ignored when deploying a stack in swarm mode with a version 3 Compose file.
So, does this mean when I'm using swarm mode and version 3 compose file to deploy it will ignore all conditions under depends_on? For example:
...ANSWER
Answered 2021-Oct-13 at 02:07Pretty correct, swarm
as a orchestration will ignore the depends_on
.
But for your scenario, depends_on
is really not necessary as you already have wait-for-it.sh
which have better control than depends_on
to assure the start order.
You can control the order of service startup and shutdown with the depends_on option. Compose always starts and stops containers in dependency order, where dependencies are determined by depends_on, links, volumes_from, and network_mode: "service:...".
However, for startup Compose does not wait until a container is “ready” (whatever that means for your particular application) - only until it’s running. There’s a good reason for this.
There are limitations to this first solution. For example, it doesn’t verify when a specific service is really ready.
Alternatively, write your own wrapper script to perform a more application-specific health check. For example, you might want to wait until Postgres is ready to accept commands
Details see Control startup and shutdown order in Compose, so you no need depends_on
in your solution.
QUESTION
Here is what I want to do. I want to run myApp1 when myApp2 is up and running. I'm trying to use wait-for-it.sh but I can't seem to make it work. =[ Please help!
...ANSWER
Answered 2021-Oct-13 at 07:23You didn't specify what to do after wait-for-it.sh returned success. Try:
command: ["./wait-for-it.sh", "myApp2:40000", "-s", "--", "", "your program arguments if any"]
QUESTION
I am deploying a new stack using AWS Fargate, I am using the cdk in python.
The docker image is build and push in ECR when I do cdk deploy
but when I do a change in my entrypoint.sh that is copied in my Dockerfile, the cdk does not detect this change.
So cdk command ends with "no changes".
How to re-build and update the docker image with the cdk?
This is my code to create the service
...ANSWER
Answered 2021-Sep-08 at 17:24The ./back
directory was a symbolic link.
This change did the trick:
QUESTION
Background
I am writing a .NET 5
application and using .net user secrets for my secret keys (database connections & passwords).
Recently I decided to learn Dockers
and update my application to work with it so that using Visual Studio
I generated a docker
file for my API
project and then created a docker-compose
file that includes the API
project & database (and some more irrelevant things for this question).
Almost everything works well. Technically, I can hard-code the secrets, and then the application will work well.
I have some secrets and most of them work fine, e.g: the database connection secrets works well, in the C#
code I do the following code and it gets the value from the .net user-secrets
:
ANSWER
Answered 2021-Aug-25 at 14:06The docker-compose.yml
is executed on your host OS (so it can use OS environment variables or vars from .env file, or from compose file, ...).
The running image - container has it's own set of env variables, in your case that means the running container has no SA_PASSWORD variable.
Your usecase would work if you had set the SA_PASSWORD Variable on your host OS.
You can check which variables are set in your container with (if your image comes with bash):
QUESTION
When I first time build containers database doesn't have enough time to initialize itself while web service and nginx is already up and thus I can't reach the server from a first run, but after second containers run everything works properly. I have tried this command: ["./wait-for-it.sh", "db:5432", "--", "python", "manage.py runserver 0.0.0.0:8000"]
to wait until database got initialized, but it didn't help me. Help me please to make my services wait until database get initialized. I've tried solutions from this post, but nothing was helpful. Help me please to make my services wait until database get initialized. Thanks in advance!
Here is my docker-compose file
...ANSWER
Answered 2021-Aug-08 at 13:35depends_on
only waits until the service has started, not until it is healthy. You should try to additionally define the condition service_healthy
to wait until a dependency is healthy:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install wait-for-it
You can use wait-for-it like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page