Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Created December 27, 2014 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vfarcic/41e3a9eca29b5e4e3b97 to your computer and use it in GitHub Desktop.
Save vfarcic/41e3a9eca29b5e4e3b97 to your computer and use it in GitHub Desktop.
#!/bin/sh
BLUE_PORT=9001
GREEN_PORT=9002
CURRENT_COLOR=$(etcdctl get /bdd/color)
if [ "$CURRENT_COLOR" = "" ]; then
CURRENT_COLOR="green"
fi
if [ "$CURRENT_COLOR" = "blue" ]; then
PORT=$GREEN_PORT
COLOR="green"
else
PORT=$BLUE_PORT
COLOR="blue"
fi
echo "Starting $COLOR deployment on port $PORT"
set +e
docker stop bdd-$COLOR
docker rm bdd-$COLOR
docker stop bdd-runner-phantomjs
docker rm bdd-runner-phantomjs
set -e
docker pull vfarcic/bdd
docker run -d --name bdd-$COLOR -p $PORT:9000 vfarcic/bdd
sleep 5
echo "Testing $COLOR deployment on port $PORT"
docker pull vfarcic/bdd-runner-phantomjs
docker run -t --rm --name bdd-runner-phantomjs vfarcic/bdd-runner-phantomjs \
--story_path data/stories/tcbdd/stories/storyEditorForm.story \
--composites_path /opt/bdd/composites/TcBddComposites.groovy \
-P url=http://172.17.42.1:$PORT -P widthHeight=1024,768
etcdctl set /bdd/color $COLOR
etcdctl set /bdd/port $PORT
etcdctl set /bdd/$COLOR/port $PORT
etcdctl set /bdd/$COLOR/status running
confd -onetime -backend etcd -node 127.0.0.1:4001
echo "Stopping $CURRENT_COLOR deployment"
sleep 10
docker stop bdd-$CURRENT_COLOR
etcdctl set /bdd/$CURRENT_COLOR/status stopped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment