Skip to content
4 changes: 3 additions & 1 deletion examples/common/scripts/etcd-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh"
cell=${CELL:-'test'}
export ETCDCTL_API=2

echo "Starting etcd..."

# Check that etcd is not already running
curl "http://${ETCD_SERVER}" > /dev/null 2>&1 && fail "etcd is already running. Exiting."

Expand All @@ -46,6 +48,6 @@ vtctl $TOPOLOGY_FLAGS VtctldCommand AddCellInfo \
$cell
set -e

echo "etcd start done..."
echo "etcd is running!"


2 changes: 2 additions & 0 deletions examples/common/scripts/mysqlctl-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ mysqlctl \
--tablet_uid $uid \
--mysql_port $mysql_port \
$action

echo -e "MySQL for tablet $alias is running!"
3 changes: 1 addition & 2 deletions examples/common/scripts/vtgate-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ grpc_port=15991
mysql_server_port=15306
mysql_server_socket_path="/tmp/mysql.sock"

# Start vtgate.
echo "Starting vtgate..."
# shellcheck disable=SC2086
vtgate \
$TOPOLOGY_FLAGS \
Expand All @@ -45,7 +45,6 @@ vtgate \
# Block waiting for vtgate to be listening
# Not the same as healthy

echo "Waiting for vtgate to be up..."
while true; do
curl -I "http://$hostname:$web_port/debug/status" >/dev/null 2>&1 && break
sleep 0.1
Expand Down
1 change: 1 addition & 0 deletions examples/common/scripts/vtorc-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ source "${script_dir}/../env.sh"
log_dir="${VTDATAROOT}/tmp"
port=16000

echo "Starting vtorc..."
vtorc \
$TOPOLOGY_FLAGS \
--logtostderr \
Expand Down
2 changes: 2 additions & 0 deletions examples/common/scripts/vttablet-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ done

# check one last time
curl -I "http://$hostname:$port/debug/status" || fail "tablet could not be started!"

echo -e "vttablet for $alias is running!"
17 changes: 14 additions & 3 deletions examples/local/101_initial_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,29 @@ CELL=zone1 ../common/scripts/vtctld-up.sh

if vtctldclient GetKeyspace commerce > /dev/null 2>&1 ; then
# Keyspace already exists: we could be running this 101 example on an non-empty VTDATAROOT
vtctldclient --server localhost:15999 SetKeyspaceDurabilityPolicy --durability-policy=semi_sync commerce || fail "Failed to set keyspace durability policy on the commerce keyspace"
vtctldclient SetKeyspaceDurabilityPolicy --durability-policy=semi_sync commerce || fail "Failed to set keyspace durability policy on the commerce keyspace"
else
# Create the keyspace with the sidecar database name and set the
# correct durability policy. Please see the comment above for
# more context on using a custom sidecar database name in your
# Vitess clusters.
vtctldclient --server localhost:15999 CreateKeyspace --sidecar-db-name="${SIDECAR_DB_NAME}" --durability-policy=semi_sync commerce || fail "Failed to create and configure the commerce keyspace"
vtctldclient CreateKeyspace --sidecar-db-name="${SIDECAR_DB_NAME}" --durability-policy=semi_sync commerce || fail "Failed to create and configure the commerce keyspace"
fi

# start mysqlctls for keyspace commerce
# because MySQL takes time to start, we do this in parallel
for i in 100 101 102; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh &
done

# without a sleep, we can have below echo happen before the echo of mysqlctl-up.sh
sleep 2
echo "Waiting for mysqlctls to start..."
wait
echo "mysqlctls are running!"

# start vttablets for keyspace commerce
for i in 100 101 102; do
CELL=zone1 TABLET_UID=$i ../common/scripts/mysqlctl-up.sh
CELL=zone1 KEYSPACE=commerce TABLET_UID=$i ../common/scripts/vttablet-up.sh
done

Expand Down
9 changes: 8 additions & 1 deletion examples/local/401_teardown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ for tablet in 100 200 300 400; do
printf -v alias '%s-%010d' 'zone1' $uid
echo "Shutting down tablet $alias"
CELL=zone1 TABLET_UID=$uid ../common/scripts/vttablet-down.sh
CELL=zone1 TABLET_UID=$uid ../common/scripts/mysqlctl-down.sh
# because MySQL takes time to stop, we do this in parallel
CELL=zone1 TABLET_UID=$uid ../common/scripts/mysqlctl-down.sh &
done

# without a sleep below, we can have the echo happen before the echo of mysqlctl-down.sh
sleep 2
echo "Waiting mysqlctl to stop..."
wait
echo "mysqlctls are stopped!"
fi
done

Expand Down