Automatically show the Controller's logs after the docker-container starts running and the status is shown.
This commit is contained in:
parent
4dc34429f8
commit
c2b17163cd
|
@ -3,7 +3,7 @@
|
|||
# For error-handling, we cannot use the "set -e" since: it has problems https://mywiki.wooledge.org/BashFAQ/105
|
||||
# So we have our own function, for use when a single command fails.
|
||||
handle_error () {
|
||||
echo -e "$1"; exit $2
|
||||
echo -e "\n\n$1\n\n"; exit $2
|
||||
}
|
||||
|
||||
# Change the working directory to the script's directory, when running from another location.
|
||||
|
@ -52,11 +52,12 @@ if [[ justInstall -eq 0 ]]; then
|
|||
sudo docker --version || handle_error "Docker was not found!" 3
|
||||
(sudo mkdir -p "$HOME"/tmp/config && sudo cp ./src/main/resources/application.yml "$HOME"/tmp/config) || true # This also replaces an existing "application.yml".
|
||||
sudo mkdir -p "$HOME"/logs || true
|
||||
(sudo docker compose up --build -d && echo -e "The Urls_Controller, Prometheus and Grafana docker-containers started running.\nWaiting 65 seconds before getting their status.") || handle_error "Could not list docker containers!" 4
|
||||
(sudo docker compose up --build -d && echo -e "\nThe Urls_Controller, Prometheus and Grafana docker-containers started running.\nWaiting 65 seconds before getting their status..\n") || handle_error "Could not list docker containers!" 4
|
||||
# Run in "detached mode" -d (in the background).
|
||||
sleep 65
|
||||
sudo docker ps -a || handle_error "Could not get the status of docker-containers!" 5
|
||||
# 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!" 5 # Using -a to get the status of failed containers as well.
|
||||
echo -e "\n\nGetting the logs of docker-container \"urlscontroller-urls_controller-1\":\n"
|
||||
sudo docker logs "$(sudo docker ps -aqf "name=^urlscontroller-urls_controller-1$")" || handle_error "Could not get the logs of docker-container \"urlscontroller-urls_controller-1\"!" 6 # Using "regex anchors" to avoid false-positives. Works even if the container is not running, thus showing the error-log.
|
||||
fi
|
||||
else
|
||||
export PATH=/opt/gradle/gradle-${gradleVersion}/bin:$PATH # Make sure the gradle is still accessible (it usually isn't without the "export").
|
||||
|
|
Loading…
Reference in New Issue