-
Notifications
You must be signed in to change notification settings - Fork 9
/
websocket.sh
51 lines (45 loc) · 1.16 KB
/
websocket.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
#!/usr/bin/env bash
# 这些 ip 是服务端的ip , 需要你手动修改对应到你的服务器地址
IPS=(
"172.16.67.210"
"172.16.67.202"
"172.16.67.203"
"172.16.67.206"
"172.16.67.207"
"172.16.67.204"
"172.16.67.205"
"172.16.67.208"
"172.16.67.209"
"172.16.68.133"
"172.16.68.134"
"172.16.68.135"
"172.16.68.131"
"172.16.68.132"
)
TYPE=$1
COUNT=$2
NUM=$3
exec_websocket(){
mkdir -p logs
for i in "${!IPS[@]}"; do
#./main -c 30000 -n 200 -u ws://172.16.67.200:8010/websocket/handshake/
echo ./main -c $COUNT -n $NUM -u ws://${IPS[$i]}:8010/websocket/handshake/
nohup ./main -c $COUNT -n $NUM -u ws://${IPS[$i]}:8010/websocket/handshake/ > logs/${IPS[$i]}.log 2>&1 &
done
}
exec_end(){
echo try to end:
ps -ef | grep main | grep websocket | awk '{print $2 " " $8 " " $14}'
ps -ef | grep main | grep websocket | awk '{print $2}' | xargs kill -9
}
exec_ifup(){
for i in "${!IPS[@]}"; do
echo ifconfig eth0:$i ${IPS[$i]} netmask $NETMASK up
ifconfig eth0:$i ${IPS[$i]} netmask $NETMASK up
done
}
case $TYPE in
"start") exec_websocket;;
"end") exec_end;;
*) echo "get unkown type $TYPE"; exit ;;
esac