Skip to content
This repository was archived by the owner on Nov 21, 2022. It is now read-only.

Commit 49e48ba

Browse files
author
Archit Sharma
committed
add conf file presence check to cleanup scripts
1 parent e91557d commit 49e48ba

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

cleanup_sarjitsu

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22

33
APP_CONF=conf/sarjitsu.conf
44

5-
source $APP_CONF
65

7-
cleanup_containers(){
8-
CLEAN_IDS=$(docker ps -a | grep -P '^.*(\ssarjitsu.*|'$METRICSTORE_CONTAINER_ID')$' | awk -F' ' '{print $1}')
9-
if [[ ! -z $CLEAN_IDS ]]; then
10-
echo "cleaning up previously created sarjitsu instances"
11-
#docker stop $CLEAN_IDS
12-
docker rm -f $CLEAN_IDS
13-
fi
6+
log(){
7+
echo -e "[$(date +'%D %H:%M:%S %Z')] - $*"
148
}
159

16-
cleanup_containers
10+
if [ ! -f $APP_CONF ]; then
11+
log "$APP_CONF doesn't exist. Taking additional steps to cleanup"
12+
log "PostgreSQL instance (if it's containerized), might still be running after this"
13+
CLEAN_IDS=$(docker ps -a | grep -e sarjitsu | awk -F' ' '{print $1}')
14+
else
15+
source $APP_CONF
16+
CLEAN_IDS=$(docker ps -a | grep -P '^.*(\ssarjitsu.*|'$METRICSTORE_CONTAINER_ID')$' | awk -F' ' '{print $1}')
17+
fi
1718

19+
if [[ ! -z $CLEAN_IDS ]]; then
20+
log "cleaning up previously created sarjitsu instances"
21+
#docker stop $CLEAN_IDS
22+
docker rm -f $CLEAN_IDS
23+
else
24+
log "nothing else to cleanup. check output of '$ docker ps -a' manually to verify"
25+
fi

0 commit comments

Comments
 (0)