-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_quick_server.sh
More file actions
executable file
·111 lines (99 loc) · 2.51 KB
/
start_quick_server.sh
File metadata and controls
executable file
·111 lines (99 loc) · 2.51 KB
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
109
110
#!/bin/bash
function help()
{
echo "Usage: [sudo] ./start_quick_server.sh [OPTIONS] [--debug]"
echo "Options:"
echo -e "\t -a | --all \t\t start nginx, redis and beanstalkd"
echo -e "\t -n | --nginx \t\t start nginx"
echo -e "\t -b | --beans \t\t start beanstalkd"
echo -e "\t -r | --redis \t\t start redis"
echo -e "\t -h | --help \t\t show help\r\n"
echo "if OPTIONS is not specified, default OPTION is \"-a(--all)\"."
echo "in default, server will start in release mode, or else it will start in debug mode if you specified \"--debug\" following OPTIONS But NOTICE that \"--debug\" dont take effect except in OPTIONS \"-a(--all)\" and \"-n(--nginx)\""
echo -e "\r\n"
}
args=$(getopt -o abrnh --long all,beanstalkd,redis,nginx,help -n 'Start Quick Server' -- "$@")
if [ $? != 0 ]; then
echo "Start Quick Server Terminating..." >&2;
exit 1;
fi
curDir=$(dirname $(readlink -f $0))
nginxDir=$curDir/openresty/nginx
toolDir=$curDir/openresty/server/actions/tools
eval set -- "$args"
declare -i debug=0
declare -i all=0
declare -i beans=0
declare -i redis=0
declare -i nginx=0
if [ $# -eq 1 ] ; then
all=1
fi
while true ; do
case "$1" in
--debug)
debug=1
shift
;;
-a|--all)
all=1
shift
;;
-b|--beanstalkd)
beans=1
shift
;;
-r|--redis)
redis=1
shift
;;
-n|--nginx)
nginx=1
shift
;;
-h|--help)
help;
exit 0
;;
--)
shift;
break
;;
*)
echo "invalid option: $1"
exit 1
;;
esac
done
#debug take effect only on command "-a | -n"
if [ nginx -ne 1 ] && [ all -ne 1 ]; then
debug = 0
fi
#start nginx
if [ $nginx -eq 1 ] || [ $all -eq 1 ]; then
if [ $debug -eq 1 ] ; then
echo -e "Start NGINX in \033[31m DEBUG \033[0m mode..."
sed -i "1a error_log logs/error.log debug;" $nginxDir/conf/nginx.conf
sed -i "$# lua_code_cache on#lua_code_cache off#g" $nginxDir/conf/nginx.conf
else
echo -e "Start NGINX in \033[31m RELEASE \033[0m mode..."
sed -i "1a error_log logs/error.log" $nginxDir/conf/nginx.conf
sed -i "$# lua_code_cache off#lua_code_cache on#g" $nginxDir/conf/nginx.conf
fi
nginx -p $(pwd) -c $nginxDir/conf/nginx.conf
echo "Start Nginx DONE..."
fi
#start redis
if [ $redis -eq 1 ] || [$all -eq 1 ]; then
$curDir/redis/bin/redis-server $curDir/conf/redis.conf
echo "Start Redis DONE"
fi
#start beanstalkd
if [ $beans -eq 1 ] || [$all -eq 1 ]; then
$curDir/beanstalkd/bin/beanstalkd > $curDir/logs/beanstalkd.log &
echo "Start beanstalkd DONE"
fi
cd $curDir
if [ $all -eq 1 ] ; then
echo -e "\033[31mStart Quick Server DONE!\033[0m"
fi