forked from Seagate/cortx-s3server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev-stops3.sh
executable file
·97 lines (85 loc) · 2.77 KB
/
dev-stops3.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
#
# Copyright (c) 2020 Seagate Technology LLC and/or its Affiliates
#
# 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.
#
# For any questions about this software or licensing,
# please email [email protected] or [email protected].
#
# Script to stop S3 server in dev environment.
# The script will stop all running instances of S3 server.
callgraph_process=0
callgraph_path="/tmp/callgraph.out"
if [ "$1" == "--callgraph" ]
then
callgraph_process=1
if ! [[ $2 =~ ^[[:space:]]*$ ]]
then
callgraph_path=$2
fi
fi
MAX_S3_INSTANCES_NUM=20
# s3 port configured in s3config.yaml
s3_config_file="/opt/seagate/cortx/s3/conf/s3config.yaml"
s3_port_from_config=`python -c '
import yaml;
print yaml.load(open("'$s3_config_file'"))["S3_SERVER_CONFIG"]["S3_SERVER_BIND_PORT"];
' | tr -d '\r\n'`
# Stop any s3backgroundserver instances
is_producer_running=1
$USE_SUDO systemctl is-active s3backgroundproducer 2>&1 > /dev/null || is_producer_running=0
if [[ $is_producer_running -eq 1 ]]; then
$USE_SUDO systemctl stop s3backgroundproducer || echo "Cannot stop s3backgroundproducer services"
fi
is_consumer_running=1
$USE_SUDO systemctl is-active s3backgroundconsumer 2>&1 > /dev/null || is_consumer_running=0
if [[ $is_consumer_running -eq 1 ]]; then
$USE_SUDO systemctl stop s3backgroundconsumer || echo "Cannot stop s3backgroundconsumer services"
fi
instance=0
while [[ $instance -lt $MAX_S3_INSTANCES_NUM ]]
do
s3port=$(($s3_port_from_config + $instance))
pidfile="/var/run/s3server.$s3port.pid"
if [[ -r $pidfile ]]; then
pidstr=$(cat $pidfile)
if [ "$pidstr" != "" ]; then
kill -s TERM $pidstr
fi # $pidstr
fi # $pidfile
((instance++))
done # while
echo "Waiting for S3 to shutdown..."
sleep 10
instance=0
while [[ $instance -lt $MAX_S3_INSTANCES_NUM ]]
do
s3port=$(($s3_port_from_config + $instance))
statuss3=$(ps -aef | grep /var/run/s3server.$s3port.pid | grep $s3port)
pidfile="/var/run/s3server.$s3port.pid"
if [ "$statuss3" != "" ]; then
if [[ -r $pidfile ]]; then
pidstr=$(cat $pidfile)
kill -9 $pidstr
fi
fi
if [[ -e $pidfile ]]; then
rm -f $pidfile
fi
((instance++))
done
if [ $callgraph_process -eq 1 ]
then
callgrind_annotate --inclusive=yes --tree=both "$callgraph_path" > "$callgraph_path".annotated
fi