Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples: only terminate vtadmin if it was started #13433

Merged
merged 14 commits into from
Jul 5, 2023
39 changes: 35 additions & 4 deletions examples/common/scripts/vtadmin-down.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
#!/bin/bash

mattlord marked this conversation as resolved.
Show resolved Hide resolved
# Copyright 2023 The Vitess Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh"

mattlord marked this conversation as resolved.
Show resolved Hide resolved
echo "Stopping vtadmin-web..."
kill -9 "$(cat "$VTDATAROOT/tmp/vtadmin-web.pid")"
function stop_vtadmin() {
local name="$1"
local file="$2"
mattlord marked this conversation as resolved.
Show resolved Hide resolved

mattlord marked this conversation as resolved.
Show resolved Hide resolved
if [[ -z ${1} || -z ${2} ]]; then
mattlord marked this conversation as resolved.
Show resolved Hide resolved
fail "A binary name and PID file must be specified when attempting to shutdown vtadmin"
fi
if [[ -e "$file" ]]; then
echo "Stopping $name..."
local pid=$(cat "$file")
kill $pid
# Wait for the process to terminate
while ps -p $pid > /dev/null; do
jfg956 marked this conversation as resolved.
Show resolved Hide resolved
sleep 1
done
else
echo "Skipping stopping $name because no pid file."
fi
}

echo "Stopping vtadmin-api..."
kill -9 "$(cat "$VTDATAROOT/tmp/vtadmin-api.pid")"
stop_vtadmin "vtadmin-web" "$VTDATAROOT/tmp/vtadmin-web.pid"
stop_vtadmin "vtadmin-api" "$VTDATAROOT/tmp/vtadmin-api.pid"
Loading