From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/mstop.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 src/mstop.sh (limited to 'src/mstop.sh') diff --git a/src/mstop.sh b/src/mstop.sh new file mode 100755 index 000000000..702d17659 --- /dev/null +++ b/src/mstop.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +set -e + +script_root=`dirname $0` + +[ -z "$BUILD_DIR" ] && BUILD_DIR=build + +if [ -e CMakeCache.txt ]; then + script_root=$PWD +elif [ -e $script_root/../${BUILD_DIR}/CMakeCache.txt ]; then + script_root=`(cd $script_root/../${BUILD_DIR}; pwd)` +fi + +[ "$#" -lt 1 ] && echo "usage: $0 [entity [id]]" && exit 1 + +name=$1 +entity=$2 +id=$3 + +run_root=$script_root/run/$name +pidpath=$run_root/out + +if [ "$entity" == "" ]; then + pfiles=`ls $pidpath/*.pid` || true +elif [ "$id" == "" ]; then + pfiles=`ls $pidpath/$entity.*.pid` || true +else + pfiles=`ls $pidpath/$entity.$id.pid` || true +fi + +MAX_RETRIES=20 + +for pidfile in $pfiles; do + pid=`cat $pidfile` + fname=`echo $pidfile | sed 's/.*\///g'` + [ "$pid" == "" ] && exit + [ $pid -eq 0 ] && exit + echo pid=$pid + extra_check="" + entity=`echo $fname | sed 's/\..*//g'` + name=`echo $fname | sed 's/\.pid$//g'` + [ "$entity" == "radosgw" ] && extra_check="-e lt-radosgw" + echo entity=$entity pid=$pid name=$name + counter=0 + signal="" + while ps -p $pid -o args= | grep -q -e $entity $extracheck ; do + if [[ "$counter" -gt MAX_RETRIES ]]; then + signal="-9" + fi + cmd="kill $signal $pid" + printf "$cmd...\n" + $cmd + sleep 1 + counter=$((counter+1)) + continue + done +done + -- cgit v1.2.3