From 29a6f8133fdb1806d7609e1f8a425c0dedec1fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Gagn=C3=A9?= Date: Mon, 3 Jul 2023 19:56:44 +0000 Subject: [PATCH 01/14] Do not error stopping vtadmin web and api if pidd files do not exist. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For fixing below. https://github.com/vitessio/vitess/issues/13432 Signed-off-by: Jean-François Gagné --- examples/common/scripts/vtadmin-down.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/common/scripts/vtadmin-down.sh b/examples/common/scripts/vtadmin-down.sh index 011e6da7f49..b677d749f09 100755 --- a/examples/common/scripts/vtadmin-down.sh +++ b/examples/common/scripts/vtadmin-down.sh @@ -2,8 +2,16 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -echo "Stopping vtadmin-web..." -kill -9 "$(cat "$VTDATAROOT/tmp/vtadmin-web.pid")" +if test -e "$VTDATAROOT/tmp/vtadmin-web.pid"; then + echo "Stopping vtadmin-web..." + kill -9 "$(cat "$VTDATAROOT/tmp/vtadmin-web.pid")" +else + echo "Skipping stopping vtadmin-web because no pid file." +fi -echo "Stopping vtadmin-api..." -kill -9 "$(cat "$VTDATAROOT/tmp/vtadmin-api.pid")" +if test -e "$VTDATAROOT/tmp/vtadmin-api.pid"; then + echo "Stopping vtadmin-api..." + kill -9 "$(cat "$VTDATAROOT/tmp/vtadmin-api.pid")" +else + echo "Skipping stopping vtadmin-web because no pid file." +fi From 41042eb6fac9c199c8063940a297c575cf27ffa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Gagn=C3=A9?= Date: Mon, 3 Jul 2023 20:09:50 +0000 Subject: [PATCH 02/14] Get rid of code duplication in vtadmin-down.sh. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-François Gagné --- examples/common/scripts/vtadmin-down.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/common/scripts/vtadmin-down.sh b/examples/common/scripts/vtadmin-down.sh index b677d749f09..4861bee7d00 100755 --- a/examples/common/scripts/vtadmin-down.sh +++ b/examples/common/scripts/vtadmin-down.sh @@ -2,16 +2,17 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -if test -e "$VTDATAROOT/tmp/vtadmin-web.pid"; then - echo "Stopping vtadmin-web..." - kill -9 "$(cat "$VTDATAROOT/tmp/vtadmin-web.pid")" -else - echo "Skipping stopping vtadmin-web because no pid file." -fi +function stop_vtadmin() { + local name="$1" + local file="$2" -if test -e "$VTDATAROOT/tmp/vtadmin-api.pid"; then - echo "Stopping vtadmin-api..." - kill -9 "$(cat "$VTDATAROOT/tmp/vtadmin-api.pid")" -else - echo "Skipping stopping vtadmin-web because no pid file." -fi + if test -e "$file"; then + echo "Stopping $name..." + kill -9 "$(cat "$file")" + else + echo "Skipping stopping $name because no pid file." + fi +} + +stop_vtadmin "vtadmin-web" "$VTDATAROOT/tmp/vtadmin-web.pid" +stop_vtadmin "vtadmin-api" "$VTDATAROOT/tmp/vtadmin-api.pid" From 5d345d6d58a2d27ee40c94e409e292957522baca Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 5 Jul 2023 14:40:35 +0000 Subject: [PATCH 03/14] Use bash test Signed-off-by: Matt Lord --- examples/common/scripts/vtadmin-down.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/common/scripts/vtadmin-down.sh b/examples/common/scripts/vtadmin-down.sh index 4861bee7d00..e6aaf127424 100755 --- a/examples/common/scripts/vtadmin-down.sh +++ b/examples/common/scripts/vtadmin-down.sh @@ -6,7 +6,7 @@ function stop_vtadmin() { local name="$1" local file="$2" - if test -e "$file"; then + if [[ -e "$file" ]]; then echo "Stopping $name..." kill -9 "$(cat "$file")" else From 94bce04611092594072113e7ffa0d049efcdcd8c Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 5 Jul 2023 14:40:57 +0000 Subject: [PATCH 04/14] Use SIGTERM and wait for process to end Signed-off-by: Matt Lord --- examples/common/scripts/vtadmin-down.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/common/scripts/vtadmin-down.sh b/examples/common/scripts/vtadmin-down.sh index e6aaf127424..a86b5af4c2e 100755 --- a/examples/common/scripts/vtadmin-down.sh +++ b/examples/common/scripts/vtadmin-down.sh @@ -8,7 +8,12 @@ function stop_vtadmin() { if [[ -e "$file" ]]; then echo "Stopping $name..." - kill -9 "$(cat "$file")" + local pid=$(cat "$file") + kill $pid + # Wait for the process to terminate + while ps -p $pid > /dev/null; do + sleep 1 + done else echo "Skipping stopping $name because no pid file." fi From 63f470d3f20885910edebaa680a951eb75d46a1c Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 5 Jul 2023 14:41:39 +0000 Subject: [PATCH 05/14] Validate function parameters Signed-off-by: Matt Lord --- examples/common/scripts/vtadmin-down.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/common/scripts/vtadmin-down.sh b/examples/common/scripts/vtadmin-down.sh index a86b5af4c2e..46546cc049c 100755 --- a/examples/common/scripts/vtadmin-down.sh +++ b/examples/common/scripts/vtadmin-down.sh @@ -6,6 +6,9 @@ function stop_vtadmin() { local name="$1" local file="$2" + if [[ -z ${1} || -z ${2} ]]; then + 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") From 63cc8bcd98226b373813ec2297b4622d12389f10 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 5 Jul 2023 14:41:50 +0000 Subject: [PATCH 06/14] Add license header Signed-off-by: Matt Lord --- examples/common/scripts/vtadmin-down.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/common/scripts/vtadmin-down.sh b/examples/common/scripts/vtadmin-down.sh index 46546cc049c..483bbc228e1 100755 --- a/examples/common/scripts/vtadmin-down.sh +++ b/examples/common/scripts/vtadmin-down.sh @@ -1,5 +1,19 @@ #!/bin/bash +# 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" function stop_vtadmin() { From c8b742f18dd1ecef651845e099c19e3d67ed9e62 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 5 Jul 2023 14:53:56 +0000 Subject: [PATCH 07/14] Move vtadmin stop function to utils Signed-off-by: Matt Lord --- examples/common/lib/utils.sh | 25 +++++++++++++++++++++++++ examples/common/scripts/vtadmin-down.sh | 24 ++---------------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/examples/common/lib/utils.sh b/examples/common/lib/utils.sh index 842a1a2cec4..991030f5b84 100644 --- a/examples/common/lib/utils.sh +++ b/examples/common/lib/utils.sh @@ -112,6 +112,31 @@ function wait_for_healthy_shard() { wait_for_shard_vreplication_engine "${keyspace}" "${shard}" } +# Stop the specified vtadmin binary name using the provided PID file. +# Example: +# stop_vtadmin_process "vtadmin-web" "$VTDATAROOT/tmp/vtadmin-web.pid" +function stop_vtadmin_process() { + if [[ -z ${1} || -z ${2} ]]; then + fail "A binary name and PID file must be specified when attempting to shutdown vtadmin" + fi + + local binary_name="${1}" + local pidfile="${2}" + local pid="" + + if [[ -e "${pidfile}" ]]; then + pid=$(cat "${pidfile}") + echo "Stopping ${binary_name}..." + kill "${pid}" + # Wait for the process to terminate + while ps -p "${pid}" > /dev/null; do + sleep 1 + done + else + echo "Skipping stopping ${binary_name} because the specified PID file (${pidfile}) does not exist." + fi +} + # Print error message and exit with error code. function fail() { echo "ERROR: ${1}" diff --git a/examples/common/scripts/vtadmin-down.sh b/examples/common/scripts/vtadmin-down.sh index 483bbc228e1..d8764553b82 100755 --- a/examples/common/scripts/vtadmin-down.sh +++ b/examples/common/scripts/vtadmin-down.sh @@ -16,25 +16,5 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -function stop_vtadmin() { - local name="$1" - local file="$2" - - if [[ -z ${1} || -z ${2} ]]; then - 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 - sleep 1 - done - else - echo "Skipping stopping $name because no pid file." - fi -} - -stop_vtadmin "vtadmin-web" "$VTDATAROOT/tmp/vtadmin-web.pid" -stop_vtadmin "vtadmin-api" "$VTDATAROOT/tmp/vtadmin-api.pid" +stop_vtadmin_process "vtadmin-web" "$VTDATAROOT/tmp/vtadmin-web.pid" +stop_vtadmin_process "vtadmin-api" "$VTDATAROOT/tmp/vtadmin-api.pid" From 81907490bfab5c76280bd1916348ed0692fb69a8 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 5 Jul 2023 15:15:41 +0000 Subject: [PATCH 08/14] Generalize simple process shutdown with timeout Signed-off-by: Matt Lord --- examples/common/lib/utils.sh | 52 ++++++++++++++---------- examples/common/scripts/consul-down.sh | 4 +- examples/common/scripts/etcd-down.sh | 4 +- examples/common/scripts/vtadmin-down.sh | 4 +- examples/common/scripts/vtctld-down.sh | 4 +- examples/common/scripts/vtgate-down.sh | 5 +-- examples/common/scripts/vtorc-down.sh | 5 ++- examples/common/scripts/vttablet-down.sh | 9 +--- 8 files changed, 45 insertions(+), 42 deletions(-) diff --git a/examples/common/lib/utils.sh b/examples/common/lib/utils.sh index 991030f5b84..84130f67d5c 100644 --- a/examples/common/lib/utils.sh +++ b/examples/common/lib/utils.sh @@ -112,29 +112,37 @@ function wait_for_healthy_shard() { wait_for_shard_vreplication_engine "${keyspace}" "${shard}" } -# Stop the specified vtadmin binary name using the provided PID file. +# Stop the specified binary name using the provided PID file. # Example: -# stop_vtadmin_process "vtadmin-web" "$VTDATAROOT/tmp/vtadmin-web.pid" -function stop_vtadmin_process() { - if [[ -z ${1} || -z ${2} ]]; then - fail "A binary name and PID file must be specified when attempting to shutdown vtadmin" - fi - - local binary_name="${1}" - local pidfile="${2}" - local pid="" - - if [[ -e "${pidfile}" ]]; then - pid=$(cat "${pidfile}") - echo "Stopping ${binary_name}..." - kill "${pid}" - # Wait for the process to terminate - while ps -p "${pid}" > /dev/null; do - sleep 1 - done - else - echo "Skipping stopping ${binary_name} because the specified PID file (${pidfile}) does not exist." - fi +# stop_process "vtadmin-web" "$VTDATAROOT/tmp/vtadmin-web.pid" +function stop_process() { + if [[ -z ${1} || -z ${2} ]]; then + fail "A binary name and PID file must be specified when attempting to shutdown vtadmin" + fi + + local binary_name="${1}" + local pidfile="${2}" + local pid="" + local wait_secs=90 + + if [[ -e "${pidfile}" ]]; then + pid=$(cat "${pidfile}") + echo "Stopping ${binary_name}..." + kill "${pid}" + # Wait for the process to terminate + for _ in $(seq 1 ${wait_secs}); do + if ! ps -p "${pid}" > /dev/null; then + break + fi + sleep 1 + done + else + echo "Skipping stopping ${binary_name} because the specified PID file (${pidfile}) does not exist." + fi + + if ps -p "${pid}" > /dev/null; then + fail "Timed out after ${wait_secs} seconds waiting for the ${binary_name} using PID file ${pidfile} to terminate" + fi } # Print error message and exit with error code. diff --git a/examples/common/scripts/consul-down.sh b/examples/common/scripts/consul-down.sh index 4da5694525a..2eccb8b5d96 100755 --- a/examples/common/scripts/consul-down.sh +++ b/examples/common/scripts/consul-down.sh @@ -18,5 +18,5 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -echo "Stopping consul..." -kill -9 `cat $VTDATAROOT/tmp/consul.pid` +stop_process "consul" "$VTDATAROOT/tmp/consul.pid" + diff --git a/examples/common/scripts/etcd-down.sh b/examples/common/scripts/etcd-down.sh index f9894f8659c..31e4e017d8e 100755 --- a/examples/common/scripts/etcd-down.sh +++ b/examples/common/scripts/etcd-down.sh @@ -18,5 +18,5 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -echo "Stopping etcd..." -kill -9 `cat $VTDATAROOT/tmp/etcd.pid` +stop_process "vttablet" "$VTDATAROOT/tmp/etcd.pid" + diff --git a/examples/common/scripts/vtadmin-down.sh b/examples/common/scripts/vtadmin-down.sh index d8764553b82..c592f0991ee 100755 --- a/examples/common/scripts/vtadmin-down.sh +++ b/examples/common/scripts/vtadmin-down.sh @@ -16,5 +16,5 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -stop_vtadmin_process "vtadmin-web" "$VTDATAROOT/tmp/vtadmin-web.pid" -stop_vtadmin_process "vtadmin-api" "$VTDATAROOT/tmp/vtadmin-api.pid" +stop_process "vtadmin-web" "$VTDATAROOT/tmp/vtadmin-web.pid" +stop_process "vtadmin-api" "$VTDATAROOT/tmp/vtadmin-api.pid" diff --git a/examples/common/scripts/vtctld-down.sh b/examples/common/scripts/vtctld-down.sh index a56d59b97e5..723b1a77bb6 100755 --- a/examples/common/scripts/vtctld-down.sh +++ b/examples/common/scripts/vtctld-down.sh @@ -18,5 +18,5 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -echo "Stopping vtctld..." -kill -9 `cat $VTDATAROOT/tmp/vtctld.pid` +stop_process "vtctld" "$VTDATAROOT/tmp/vtctld.pid" + diff --git a/examples/common/scripts/vtgate-down.sh b/examples/common/scripts/vtgate-down.sh index 3eea5fdf94d..c25036c7955 100755 --- a/examples/common/scripts/vtgate-down.sh +++ b/examples/common/scripts/vtgate-down.sh @@ -18,6 +18,5 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -# Stop vtgate. -echo "Stopping vtgate..." -kill `cat $VTDATAROOT/tmp/vtgate.pid` +stop_process "vtgate" "$VTDATAROOT/tmp/vtgate.pid" + diff --git a/examples/common/scripts/vtorc-down.sh b/examples/common/scripts/vtorc-down.sh index f4d2e4cb8a0..1cea5e3f787 100755 --- a/examples/common/scripts/vtorc-down.sh +++ b/examples/common/scripts/vtorc-down.sh @@ -2,6 +2,7 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -echo "Stopping vtorc." -kill -9 "$(cat "$VTDATAROOT/tmp/vtorc.pid")" +echo "Stopping vtorc..." + +stop_process "vttablet" "$VTDATAROOT/tmp/vtorc.pid" diff --git a/examples/common/scripts/vttablet-down.sh b/examples/common/scripts/vttablet-down.sh index 3de266def76..b81b94674ea 100755 --- a/examples/common/scripts/vttablet-down.sh +++ b/examples/common/scripts/vttablet-down.sh @@ -19,12 +19,7 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -printf -v tablet_dir 'vt_%010d' $TABLET_UID -pid=`cat $VTDATAROOT/$tablet_dir/vttablet.pid` - -kill $pid - -# Wait for vttablet to die. -while ps -p $pid > /dev/null; do sleep 1; done +printf -v tablet_dir 'vt_%010d' "$TABLET_UID" +stop_process "vttablet" "$VTDATAROOT/$tablet_dir/vttablet.pid" From c153b4bb3b6756600f0cb1d858ce7a5d8c60a729 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 5 Jul 2023 15:17:22 +0000 Subject: [PATCH 09/14] Correct output Signed-off-by: Matt Lord --- examples/common/lib/utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/common/lib/utils.sh b/examples/common/lib/utils.sh index 84130f67d5c..1d1f211e466 100644 --- a/examples/common/lib/utils.sh +++ b/examples/common/lib/utils.sh @@ -117,7 +117,7 @@ function wait_for_healthy_shard() { # stop_process "vtadmin-web" "$VTDATAROOT/tmp/vtadmin-web.pid" function stop_process() { if [[ -z ${1} || -z ${2} ]]; then - fail "A binary name and PID file must be specified when attempting to shutdown vtadmin" + fail "A binary name and PID file must be specified when attempting to shutdown a process" fi local binary_name="${1}" From 095e12eb8ededecad34379fc21063a668da67b01 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 5 Jul 2023 15:23:26 +0000 Subject: [PATCH 10/14] Remove now redundant log message Signed-off-by: Matt Lord --- examples/common/scripts/vtorc-down.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/common/scripts/vtorc-down.sh b/examples/common/scripts/vtorc-down.sh index 1cea5e3f787..99a56a2e98b 100755 --- a/examples/common/scripts/vtorc-down.sh +++ b/examples/common/scripts/vtorc-down.sh @@ -2,7 +2,5 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -echo "Stopping vtorc..." - stop_process "vttablet" "$VTDATAROOT/tmp/vtorc.pid" From 0a9d320259baae635458bfe276ca81b14804b03e Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 5 Jul 2023 15:34:44 +0000 Subject: [PATCH 11/14] Corrections Signed-off-by: Matt Lord --- examples/common/scripts/etcd-down.sh | 2 +- examples/common/scripts/vtorc-down.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/common/scripts/etcd-down.sh b/examples/common/scripts/etcd-down.sh index 31e4e017d8e..dbc5d8b1fd6 100755 --- a/examples/common/scripts/etcd-down.sh +++ b/examples/common/scripts/etcd-down.sh @@ -18,5 +18,5 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -stop_process "vttablet" "$VTDATAROOT/tmp/etcd.pid" +stop_process "etcd" "$VTDATAROOT/tmp/etcd.pid" diff --git a/examples/common/scripts/vtorc-down.sh b/examples/common/scripts/vtorc-down.sh index 99a56a2e98b..9161e1aa55b 100755 --- a/examples/common/scripts/vtorc-down.sh +++ b/examples/common/scripts/vtorc-down.sh @@ -2,5 +2,5 @@ source "$(dirname "${BASH_SOURCE[0]:-$0}")/../env.sh" -stop_process "vttablet" "$VTDATAROOT/tmp/vtorc.pid" +stop_process "vtorc" "$VTDATAROOT/tmp/vtorc.pid" From b16e3031243f7b4c944207a8fd99bdfee4c9f68f Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 5 Jul 2023 15:49:00 +0000 Subject: [PATCH 12/14] Add missing license header to modified file Signed-off-by: Matt Lord --- examples/common/scripts/vtorc-down.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/common/scripts/vtorc-down.sh b/examples/common/scripts/vtorc-down.sh index 9161e1aa55b..084c3e8e541 100755 --- a/examples/common/scripts/vtorc-down.sh +++ b/examples/common/scripts/vtorc-down.sh @@ -1,5 +1,19 @@ #!/bin/bash +# 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" stop_process "vtorc" "$VTDATAROOT/tmp/vtorc.pid" From 693501ca87c2f5282bc5eef408a0028d1ca28729 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 5 Jul 2023 15:55:14 +0000 Subject: [PATCH 13/14] Only check PID if we killed it Signed-off-by: Matt Lord --- examples/common/lib/utils.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/common/lib/utils.sh b/examples/common/lib/utils.sh index 1d1f211e466..5887fee0d3b 100644 --- a/examples/common/lib/utils.sh +++ b/examples/common/lib/utils.sh @@ -129,6 +129,7 @@ function stop_process() { pid=$(cat "${pidfile}") echo "Stopping ${binary_name}..." kill "${pid}" + # Wait for the process to terminate for _ in $(seq 1 ${wait_secs}); do if ! ps -p "${pid}" > /dev/null; then @@ -136,13 +137,12 @@ function stop_process() { fi sleep 1 done + if ps -p "${pid}" > /dev/null; then + fail "Timed out after ${wait_secs} seconds waiting for the ${binary_name} using PID file ${pidfile} to terminate" + fi else echo "Skipping stopping ${binary_name} because the specified PID file (${pidfile}) does not exist." fi - - if ps -p "${pid}" > /dev/null; then - fail "Timed out after ${wait_secs} seconds waiting for the ${binary_name} using PID file ${pidfile} to terminate" - fi } # Print error message and exit with error code. From 4c7bc58eb3e224b311c7f72d5094f78b5fc1f598 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 5 Jul 2023 15:58:36 +0000 Subject: [PATCH 14/14] Remove mix of spaces and tabs Signed-off-by: Matt Lord --- examples/common/lib/utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/common/lib/utils.sh b/examples/common/lib/utils.sh index 5887fee0d3b..2f80c9daed0 100644 --- a/examples/common/lib/utils.sh +++ b/examples/common/lib/utils.sh @@ -133,7 +133,7 @@ function stop_process() { # Wait for the process to terminate for _ in $(seq 1 ${wait_secs}); do if ! ps -p "${pid}" > /dev/null; then - break + break fi sleep 1 done