-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.sh
executable file
·108 lines (97 loc) · 2.32 KB
/
run.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
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
work_path=$(dirname $0)
cd $work_path
work_path=$(pwd)
server=kimserver
server_file=$work_path/bin/$server
core_path=$work_path/src/core/
so_path=$work_path/src/modules/
core_proto_path=$core_path/protobuf
kill_process() {
echo '<------------------'
name=$1
local processes=$(ps -ef | grep $name | grep -v 'grep\|log\|vim' | awk '{if ($2 > 1) print $2;}')
for p in $processes; do
echo "kill pid: $p."
kill $p
[ $? -ne 0 ] && echo "kill pid: $p failed!"
done
}
cat_process() {
sleep 1
local name=$1
ps -ef | grep -i $name | grep -v 'grep\|log\|vim' | awk '{ print $2, $8 }'
}
compile_core() {
cd $core_path
[ $1x == 'all'x ] && make clean
make -j8
[ $? -ne 0 ] && exit 1
}
compile_so() {
cd $so_path
local modules_dirs=$(find . -name 'module*' -type d)
for dir in $modules_dirs; do
cd $dir
[ $1x == 'all'x ] && make clean
make -j8
[ $? -ne 0 ] && exit 1
done
}
gen_proto() {
cd $core_proto_path
if [ ! -f http.pb.cc ]; then
[ ! -x gen_proto.sh ] && chmod +x gen_proto.sh
./gen_proto.sh
[ $? -ne 0 ] && echo 'gen protobuf file failed!' && exit 1
fi
}
run() {
if [ $(uname -s) == "Darwin" ]; then
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/mariadb/
else
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/mariadb/
fi
cd $work_path/bin
./$server config.json
echo '<------------------'
}
if [ $1x == 'help'x ]; then
echo './run.sh'
echo './run.sh all'
echo './run.sh compile'
echo './run.sh compile so'
echo './run.sh compile so all'
echo './run.sh compile core'
echo './run.sh compile core all'
exit 1
elif [ $1x == 'kill'x ]; then
kill_process $server
exit 1
elif [ $1x == 'compile'x ]; then
if [ $2x == 'so'x ]; then
gen_proto
compile_so $3
elif [ $2x == 'core'x ]; then
gen_proto
compile_core $3
else
compile_core $2
compile_so $2
fi
exit 1
elif [ $1x == 'all'x ]; then
gen_proto
compile_core $1
compile_so $1
else
if [ $# -gt 0 ]; then
echo 'invalid param. (./run.sh help)'
exit 1
fi
compile_core
compile_so
fi
kill_process $server
run
cat_process $server