Skip to content

Commit 7d84776

Browse files
author
Matthew Fisher
committed
feat(contrib): kill containers on success or failure
1 parent 44f6cfe commit 7d84776

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

contrib/ci/test.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ puts-error() {
1010
echo "!!! $@"
1111
}
1212

13+
kill-containers() {
14+
puts-step "destroying containers"
15+
docker rm -f "$MINIO_JOB" "$PG_JOB"
16+
}
17+
1318
# make sure we are in this dir
1419
CURRENT_DIR=$(cd $(dirname $0); pwd)
1520

@@ -49,6 +54,9 @@ MINIO_JOB=$(docker run -dv $CURRENT_DIR/tmp/aws-admin:/var/run/secrets/deis/mini
4954
# boot postgres, linking the minio container and setting DEIS_MINIO_SERVICE_HOST and DEIS_MINIO_SERVICE_PORT
5055
PG_JOB=$(docker run -d --link $MINIO_JOB:minio -e BACKUP_FREQUENCY=1s -e DEIS_MINIO_SERVICE_HOST=minio -e DEIS_MINIO_SERVICE_PORT=9000 -v $CURRENT_DIR/tmp/creds:/var/run/secrets/deis/database/creds -v $CURRENT_DIR/tmp/aws-user:/etc/wal-e.d/env $1)
5156

57+
# kill containers when this script exits or errors out
58+
trap kill-containers INT TERM
59+
5260
# wait for postgres to boot
5361
puts-step "sleeping for 90s while postgres is booting..."
5462
sleep 90s
@@ -70,8 +78,3 @@ if [[ ! "$NUM_BACKUPS" -eq "5" ]]; then
7078
puts-error "did not find 5 base backups, which is the default (found $NUM_BACKUPS)"
7179
exit 1
7280
fi
73-
74-
# success, kill off jobs
75-
puts-step "destroying containers"
76-
docker rm -f $MINIO_JOB
77-
docker rm -f $PG_JOB

0 commit comments

Comments
 (0)