Improve the UX of the "installAndRun.sh" script.

This commit is contained in:
Lampros Smyrnaios 2023-10-09 17:28:22 +03:00
parent fb2877dbe8
commit def21b991d
1 changed files with 6 additions and 3 deletions

View File

@ -64,11 +64,14 @@ if [[ justInstall -eq 0 ]]; then
(sudo docker compose -f prometheus/docker-compose-prometheus.yml up --build -d && echo -e "\nThe Prometheus and Grafana docker-containers started running.\n") || handle_error "Could not build and/or run the 'prometheus' and/or 'grafana' docker containers!" 5 (sudo docker compose -f prometheus/docker-compose-prometheus.yml up --build -d && echo -e "\nThe Prometheus and Grafana docker-containers started running.\n") || handle_error "Could not build and/or run the 'prometheus' and/or 'grafana' docker containers!" 5
fi fi
echo -e "Waiting 65 seconds before getting the status..\n" echo -e "Waiting 20 seconds before getting the status..\n"
sleep 65 sleep 20
# 20 seconds are enough to check if there is an immediate fatal error with one of the docker images. This will cover the problematic configuration case for Prometheus and Grafana containers.
sudo docker ps -a || handle_error "Could not get the status of docker-containers!" 6 # Using -a to get the status of failed containers as well. sudo docker ps -a || handle_error "Could not get the status of docker-containers!" 6 # Using -a to get the status of failed containers as well.
echo -e "\n\nGetting the logs of docker-container \"urls_controller\":\n" echo -e "\n\nGetting the logs of docker-container \"urls_controller\":\n"
sudo docker logs "$(sudo docker ps -aqf "name=^urls_controller$")" || handle_error "Could not get the logs of docker-container \"urls_controller\"!" 7 # Using "regex anchors" to avoid false-positives. Works even if the container is not running, thus showing the error-log. sudo docker logs urls_controller -f || handle_error "Could not get the logs of docker-container \"urls_controller\"!" 7 # Using "regex anchors" to avoid false-positives. Works even if the container is not running, thus showing the error-log.
# Use just the container-name and the "-f" parameter to indicate that we want to follow on logs updates, until we specify to unfollow them (with ctrl+c).
# This way we do not need to run the "docker logs" again and again, not checking the the container-id each time.
fi fi
else else
export PATH=/opt/gradle/gradle-${gradleVersion}/bin:$PATH # Make sure the gradle is still accessible (it usually isn't without the "export"). export PATH=/opt/gradle/gradle-${gradleVersion}/bin:$PATH # Make sure the gradle is still accessible (it usually isn't without the "export").