-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.sh
executable file
·49 lines (47 loc) · 972 Bytes
/
util.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
work_dir=`pwd`
bin_vec=(``)
bin_vec[0]="stop"
stop() {
echo "stop"
openresty -p ${work_dir} -s stop
}
bin_vec[1]="start"
start() {
echo "start"
openresty -p ${work_dir} -c ${work_dir}/conf/nginx.conf
sleep 1
pid=`ps -ef | grep "openresty" | grep -v "grep" | awk '{print $2}'`
echo $pid > pid
}
bin_vec[2]="info"
info() {
echo "info"
netstat -nlt | grep 8080
lsof -i tcp:8080
}
bin_vec[3]="restart"
restart() {
echo "restart"
openresty -p ${work_dir} -s stop
openresty -p ${work_dir} -c ${work_dir}/conf/nginx.conf
sleep 1
pid=`ps -ef | grep "openresty" | grep -v "grep" | awk '{print $2}'`
echo $pid > pid
}
bin_name=$1
help=1
for((i=0;i<${#bin_vec[*]};i++))
do
if [ "${bin_vec[$i]}" = "$bin_name" ];then
shift 1
help=0
${bin_vec[$i]}
fi
done
if [ $help -eq 1 ];then
echo "opt is :"
for((i=0;i<${#bin_vec[*]};i++))
do
echo "[${bin_vec[$i]}]"
done
fi