]>
Commit | Line | Data |
---|---|---|
11fdf7f2 | 1 | #!/usr/bin/env bash |
7c673cae FG |
2 | |
3 | set -e | |
4 | ||
5 | script_root=`dirname $0` | |
6 | ||
9f95a23c TL |
7 | [ -z "$BUILD_DIR" ] && BUILD_DIR=build |
8 | ||
7c673cae FG |
9 | if [ -e CMakeCache.txt ]; then |
10 | script_root=$PWD | |
9f95a23c TL |
11 | elif [ -e $script_root/../${BUILD_DIR}/CMakeCache.txt ]; then |
12 | script_root=`(cd $script_root/../${BUILD_DIR}; pwd)` | |
7c673cae FG |
13 | fi |
14 | ||
15 | [ "$#" -lt 1 ] && echo "usage: $0 <name> [entity [id]]" && exit 1 | |
16 | ||
17 | name=$1 | |
18 | entity=$2 | |
19 | id=$3 | |
20 | ||
21 | run_root=$script_root/run/$name | |
22 | pidpath=$run_root/out | |
23 | ||
24 | if [ "$entity" == "" ]; then | |
25 | pfiles=`ls $pidpath/*.pid` || true | |
26 | elif [ "$id" == "" ]; then | |
27 | pfiles=`ls $pidpath/$entity.*.pid` || true | |
28 | else | |
29 | pfiles=`ls $pidpath/$entity.$id.pid` || true | |
30 | fi | |
31 | ||
11fdf7f2 TL |
32 | MAX_RETRIES=20 |
33 | ||
7c673cae FG |
34 | for pidfile in $pfiles; do |
35 | pid=`cat $pidfile` | |
36 | fname=`echo $pidfile | sed 's/.*\///g'` | |
7c673cae FG |
37 | [ "$pid" == "" ] && exit |
38 | [ $pid -eq 0 ] && exit | |
39 | echo pid=$pid | |
40 | extra_check="" | |
41 | entity=`echo $fname | sed 's/\..*//g'` | |
11fdf7f2 | 42 | name=`echo $fname | sed 's/\.pid$//g'` |
7c673cae | 43 | [ "$entity" == "radosgw" ] && extra_check="-e lt-radosgw" |
11fdf7f2 TL |
44 | echo entity=$entity pid=$pid name=$name |
45 | counter=0 | |
46 | signal="" | |
7c673cae | 47 | while ps -p $pid -o args= | grep -q -e $entity $extracheck ; do |
11fdf7f2 TL |
48 | if [[ "$counter" -gt MAX_RETRIES ]]; then |
49 | signal="-9" | |
50 | fi | |
7c673cae | 51 | cmd="kill $signal $pid" |
11fdf7f2 | 52 | printf "$cmd...\n" |
7c673cae FG |
53 | $cmd |
54 | sleep 1 | |
11fdf7f2 | 55 | counter=$((counter+1)) |
7c673cae FG |
56 | continue |
57 | done | |
58 | done | |
59 |