#!/bin/bash # set -eo pipefail export CONSUL_NUM_INSTANCES=${CONSUL_NUM_INSTANCES:-3} echo " => stopping consul" fleetctl stop -block-attempts=10 \ $(eval echo "consul-server@{1..$CONSUL_NUM_INSTANCES}.service") \ consul-agent.service # FIXME: sometimes it takes awhile for systemd to stop things... # if we go right to destroy this can leave services running... echo " => destroying consul" fleetctl destroy \ $(eval echo "consul-server@{1..$CONSUL_NUM_INSTANCES}.service") \ consul-agent.service echo " => sleeping and then submitting consul" SCRIPT=`readlink -f "$0"` SCRIPTPATH=`dirname "$SCRIPT"` sleep 5 fleetctl load \ $(eval echo "$SCRIPTPATH/consul-server@{1..$CONSUL_NUM_INSTANCES}.service") \ "$SCRIPTPATH/consul-agent.service" echo " => starting consul" fleetctl start \ $(eval echo "consul-server@{1..$CONSUL_NUM_INSTANCES}.service") \ consul-agent.service