vitess.io/vitess@v0.16.2/examples/region_sharding/301_teardown.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2019 The Vitess Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  # We should not assume that any of the steps have been executed.
    18  # This makes it possible for a user to cleanup at any point.
    19  
    20  source ../common/env.sh
    21  
    22  ../common/scripts/vtadmin-down.sh
    23  
    24  ../common/scripts/vtorc-down.sh
    25  
    26  ../common/scripts/vtgate-down.sh
    27  
    28  for tablet in 100 200 300 400 500; do
    29  	if vtctlclient --server localhost:15999 GetTablet zone1-$tablet >/dev/null 2>&1; then
    30  		printf -v alias '%s-%010d' 'zone1' $tablet
    31  		echo "Shutting down tablet $alias"
    32  		CELL=zone1 TABLET_UID=$tablet ../common/scripts/vttablet-down.sh
    33  		CELL=zone1 TABLET_UID=$tablet ../common/scripts/mysqlctl-down.sh
    34  	fi
    35  done
    36  
    37  ../common/scripts/vtctld-down.sh
    38  
    39  if [ "${TOPO}" = "zk2" ]; then
    40  	CELL=zone1 ../common/scripts/zk-down.sh
    41  elif [ "${TOPO}" = "k8s" ]; then
    42  	CELL=zone1 ../common/scripts/k3s-down.sh
    43  else
    44  	CELL=zone1 ../common/scripts/etcd-down.sh
    45  fi
    46  
    47  # pedantic check: grep for any remaining processes
    48  
    49  if [ -n "$VTDATAROOT" ]; then
    50  	if pgrep -f -l "$VTDATAROOT" >/dev/null; then
    51  		echo "ERROR: Stale processes detected! It is recommended to manually kill them:"
    52  		pgrep -f -l "$VTDATAROOT"
    53  	else
    54  		echo "All good! It looks like every process has shut down"
    55  	fi
    56  
    57  	# shellcheck disable=SC2086
    58  	rm -r ${VTDATAROOT:?}/*
    59  fi
    60  
    61  disown -a