Skip to content

Commit 6c0c41f

Browse files
author
Matthew Fisher
committed
Merge pull request #70 from bacongobbler/trap-kill-containers
feat(contrib): kill containers on success or failure
2 parents beadee5 + 7d84776 commit 6c0c41f

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

@@ -51,6 +56,9 @@ MINIO_JOB=$(docker run -dv $CURRENT_DIR/tmp/aws-admin:/var/run/secrets/deis/mini
5156
# boot postgres, linking the minio container and setting DEIS_MINIO_SERVICE_HOST and DEIS_MINIO_SERVICE_PORT
5257
PG_JOB=$(docker run -d --link $MINIO_JOB:minio -e BACKUP_FREQUENCY=1s -e DATABASE_STORAGE=minio -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:/var/run/secrets/deis/objectstore/creds $1)
5358

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

0 commit comments

Comments
 (0)