Caporegime
Hi,
So I have a bash file that is doing things.
Basically it runs docker-compose to fire up some containers, then checks the docker logs for a specific string which indicates that the containers have started successfully.
At the moment it looks something like this.
The issue is because this is running in a CI sometimes it can be quite slow to boot things up. So even with a sleep 90, it then moves onto the the checks and thinks they've failed.
So what I'm thinking is loop 'n' times after the initial sleep with a little extra sleep in between each loop and if gets to the last loop and still fails then so be it.
But the above is about the limits to my bash knowledge.
Any assistance would be appreciated.
So I have a bash file that is doing things.
Basically it runs docker-compose to fire up some containers, then checks the docker logs for a specific string which indicates that the containers have started successfully.
At the moment it looks something like this.
Code:
docker-compose up &
sleep 90
container1=$(docker logs root_container1 2>&1 | grep "Success App has booted!")
container2=$(docker logs root_container2 2>&1 | grep "Running on port 3000")
# Check App
echo "Check if App is running, let us know if something isn't working"
if ! [ "$container1" ]; then
echo "App is not running"
fi
if [ "$container1" ]; then
echo "App is running"
fi
if ! [ "$container2" ]; then
echo "App is not running"
fi
if [ "$container2" ]; then
echo "App is running"
fi
# Stop App
echo "Take down the containers"
docker-compose down
if ! [ "$container1" ] || ! [ "$container2" ]; then
exit 1
fi
The issue is because this is running in a CI sometimes it can be quite slow to boot things up. So even with a sleep 90, it then moves onto the the checks and thinks they've failed.
So what I'm thinking is loop 'n' times after the initial sleep with a little extra sleep in between each loop and if gets to the last loop and still fails then so be it.
But the above is about the limits to my bash knowledge.
Any assistance would be appreciated.