vitess.io/vitess@v0.16.2/examples/common/scripts/vttablet-up.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 source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" 18 19 cell=${CELL:-'test'} 20 keyspace=${KEYSPACE:-'test_keyspace'} 21 shard=${SHARD:-'0'} 22 uid=$TABLET_UID 23 mysql_port=$[17000 + $uid] 24 port=$[15000 + $uid] 25 grpc_port=$[16000 + $uid] 26 printf -v alias '%s-%010d' $cell $uid 27 printf -v tablet_dir 'vt_%010d' $uid 28 tablet_hostname='' 29 printf -v tablet_logfile 'vttablet_%010d_querylog.txt' $uid 30 31 tablet_type=replica 32 if [[ "${uid: -1}" -gt 1 ]]; then 33 tablet_type=rdonly 34 fi 35 36 echo "Starting vttablet for $alias..." 37 38 # shellcheck disable=SC2086 39 vttablet \ 40 $TOPOLOGY_FLAGS \ 41 --log_dir $VTDATAROOT/tmp \ 42 --log_queries_to_file $VTDATAROOT/tmp/$tablet_logfile \ 43 --tablet-path $alias \ 44 --tablet_hostname "$tablet_hostname" \ 45 --init_keyspace $keyspace \ 46 --init_shard $shard \ 47 --init_tablet_type $tablet_type \ 48 --health_check_interval 5s \ 49 --backup_storage_implementation file \ 50 --file_backup_storage_root $VTDATAROOT/backups \ 51 --restore_from_backup \ 52 --port $port \ 53 --grpc_port $grpc_port \ 54 --service_map 'grpc-queryservice,grpc-tabletmanager,grpc-updatestream' \ 55 --pid_file $VTDATAROOT/$tablet_dir/vttablet.pid \ 56 --vtctld_addr http://$hostname:$vtctld_web_port/ \ 57 --disable_active_reparents \ 58 --throttler-config-via-topo --heartbeat_enable --heartbeat_interval=250ms --heartbeat_on_demand_duration=5s \ 59 > $VTDATAROOT/$tablet_dir/vttablet.out 2>&1 & 60 61 # Block waiting for the tablet to be listening 62 # Not the same as healthy 63 64 for i in $(seq 0 300); do 65 curl -I "http://$hostname:$port/debug/status" >/dev/null 2>&1 && break 66 sleep 0.1 67 done 68 69 # check one last time 70 curl -I "http://$hostname:$port/debug/status" || fail "tablet could not be started!"