blob: 013fbe1e058184d123eadd096162badd512bbd7a [file] [log] [blame]
adheli.tavares1f339f82023-02-17 15:14:07 +00001#!/bin/bash
2#
3# ============LICENSE_START====================================================
adheli.tavares80e382e2024-05-01 14:08:35 +01004# Copyright (C) 2023-2024 Nordix Foundation.
adheli.tavares1f339f82023-02-17 15:14:07 +00005# =============================================================================
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18# SPDX-License-Identifier: Apache-2.0
19# ============LICENSE_END======================================================
20
21echo "Shut down started!"
22if [ -z "${WORKSPACE}" ]; then
23 WORKSPACE=$(git rev-parse --show-toplevel)
24 export WORKSPACE
25fi
adheli.tavares80e382e2024-05-01 14:08:35 +010026
27# docker compose fails when not running CSIT
28if [ -z "$ROBOT_LOG_DIR" ]; then
29 export ROBOT_LOG_DIR=/tmp/
30 export ROBOT_FILES=none
31 export PROJECT=api
32fi
33
adheli.tavares1f339f82023-02-17 15:14:07 +000034COMPOSE_FOLDER="${WORKSPACE}"/compose
35
adheli.tavares5980fb42023-03-16 16:31:11 +000036cd ${COMPOSE_FOLDER}
37
38source export-ports.sh > /dev/null 2>&1
39source get-versions.sh > /dev/null 2>&1
adheli.tavares1f339f82023-02-17 15:14:07 +000040
41echo "Collecting logs from docker compose containers..."
adheli.tavares80e382e2024-05-01 14:08:35 +010042rm -rf docker_compose.log
43
44# this will collect logs by service instead of mixing all together
45containers=$(docker compose ps --all --format '{{.Service}}')
46
47IFS=$'\n' read -d '' -r -a item_list <<< "$containers"
48for item in "${item_list[@]}"
49do
50 if [ -n "$item" ]; then
51 echo "======== Logs from ${item} ========" >> docker_compose.log
52 docker compose logs $item >> docker_compose.log
53 echo "===================================" >> docker_compose.log
54 fi
55done
56
adheli.tavares1f339f82023-02-17 15:14:07 +000057cat docker_compose.log
58
59echo "Tearing down containers..."
adheli.tavares80e382e2024-05-01 14:08:35 +010060docker compose down -v --remove-orphans
adheli.tavares5980fb42023-03-16 16:31:11 +000061
62cd ${WORKSPACE}