blob: 5811a3e13c898a72ac950f9c8d39a5c0864ca602 [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
adheli.tavaresd802fd92024-08-15 12:39:19 +010027database=postgres
adheli.tavares36127472024-07-02 11:51:35 +010028
adheli.tavaresd802fd92024-08-15 12:39:19 +010029while [[ $# -gt 0 ]]
30do
31 key="$1"
32
33 case $key in
34 --mariadb)
35 database=mariadb
36 shift
37 ;;
38 --postgres)
39 database=postgres
40 shift
41 ;;
42 *)
43 component="$1"
44 shift
45 ;;
46 esac
47done
48
49if [ -z "$component" ]; then
50 export component=api
adheli.tavares80e382e2024-05-01 14:08:35 +010051fi
52
adheli.tavares1f339f82023-02-17 15:14:07 +000053COMPOSE_FOLDER="${WORKSPACE}"/compose
54
adheli.tavares5980fb42023-03-16 16:31:11 +000055cd ${COMPOSE_FOLDER}
56
57source export-ports.sh > /dev/null 2>&1
58source get-versions.sh > /dev/null 2>&1
adheli.tavares1f339f82023-02-17 15:14:07 +000059
60echo "Collecting logs from docker compose containers..."
adheli.tavaresf11e6d92024-08-01 14:18:34 +010061rm -rf *.log
adheli.tavares80e382e2024-05-01 14:08:35 +010062
adheli.tavaresd802fd92024-08-15 12:39:19 +010063#COMPOSE_FILES="-f compose.${database}.yml -f compose.pdp.scale.yml -f compose.acm.scale.yml"
64
adheli.tavares80e382e2024-05-01 14:08:35 +010065# this will collect logs by service instead of mixing all together
66containers=$(docker compose ps --all --format '{{.Service}}')
67
68IFS=$'\n' read -d '' -r -a item_list <<< "$containers"
69for item in "${item_list[@]}"
70do
71 if [ -n "$item" ]; then
adheli.tavaresf11e6d92024-08-01 14:18:34 +010072 docker compose logs $item >> $item.log
adheli.tavares80e382e2024-05-01 14:08:35 +010073 fi
74done
75
adheli.tavares1f339f82023-02-17 15:14:07 +000076echo "Tearing down containers..."
adheli.tavares80e382e2024-05-01 14:08:35 +010077docker compose down -v --remove-orphans
adheli.tavares5980fb42023-03-16 16:31:11 +000078
79cd ${WORKSPACE}