Skip to content

Commit

Permalink
fix - check for running docker-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
DocX committed Mar 15, 2017
1 parent 48c4a15 commit 2813fa9
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions dex
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,24 @@ fi
# Lets assume the default project name derivated from dir name
COMPOSE_CONTAINER_NAME=$(basename $(pwd) | tr -d '[\-_]')_${SERVICE_NAME}_1

CONTAINER_RUNS_TEST=$(docker ps -q -f name=$COMPOSE_CONTAINER_NAME)
if [ -z "$CONTAINER_RUNS_TEST" ]; then
echo "Container $COMPOSE_CONTAINER_NAME not running... Starting docker-sync and docker-compose"
# CHECK DOCKER-SYNC RUNNING
DOCKER_SYNC_PID=$(cat .docker-sync/daemon.pid 2> /dev/null)
if ( [ -z "$DOCKER_SYNC_PID" ] || ! kill -0 $DOCKER_SYNC_PID ); then
echo "Docker-sync is not running."
echo "Starting 'docker-sync' in background..."
DOCKER_SYNC_VERSION=$(docker-sync -v)

# start sync always - it just fails if it is already running
if ! ( echo $DOCKER_SYNC_VERSION | fgrep '0.2.' > /dev/null ); then
echo "ERROR: Docker-sync version $DOCKER_SYNC_VERSION is not supported! Please install docker-sync 0.2.*."
exit 1
fi
docker-sync start -d
fi

# CHECK DOCKER CONTAINER RUNNNING
CONTAINER_RUNS_TEST=$(docker ps -q -f name=$COMPOSE_CONTAINER_NAME)
if [ -z "$CONTAINER_RUNS_TEST" ]; then
echo "Container $COMPOSE_CONTAINER_NAME not running... Starting 'docker-compose up' in background"

# start docker-compose if it is not running
if [ -f docker-compose.override.yml ]; then
Expand Down

0 comments on commit 2813fa9

Please sign in to comment.