From def21b991d8ab0a2ed9bc47821bd25952ce93120 Mon Sep 17 00:00:00 2001 From: LSmyrnaios Date: Mon, 9 Oct 2023 17:28:22 +0300 Subject: [PATCH] Improve the UX of the "installAndRun.sh" script. --- installAndRun.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/installAndRun.sh b/installAndRun.sh index 336ed01..33fe3be 100755 --- a/installAndRun.sh +++ b/installAndRun.sh @@ -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 fi - echo -e "Waiting 65 seconds before getting the status..\n" - sleep 65 + echo -e "Waiting 20 seconds before getting the status..\n" + 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. 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 else export PATH=/opt/gradle/gradle-${gradleVersion}/bin:$PATH # Make sure the gradle is still accessible (it usually isn't without the "export").