-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathrun_jormungandr.sh
executable file
·86 lines (73 loc) · 2.24 KB
/
run_jormungandr.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
#!/usr/bin/env bash
file=/usr/src/app/jormungandr.wsgi
monitor_cache2="name=monitor,items=100"
function show_help() {
cat << EOF
Usage: ${0##*/} -m monitor-process -r max-requests
-m [0|1] activate monitor-process
-r max-requests before reload for jormungandr worker
-g Optional: gormungandr url for route_schedules API (Example: http://gormungandr)
-v Optional: gormungandr version API : route_schedules(1), route_schedules and journeys(2)
EOF
}
while getopts "m:r:c:g:v:h" opt; do
case $opt in
m) monitor_processes=$OPTARG
;;
r) app_max_requests=$OPTARG
;;
c) jormun_cache_items=$OPTARG
;;
g) gormungandr_url=$OPTARG
;;
v) gormungandr_version=$OPTARG
;;
h|\?)
show_help
exit 1
;;
esac
done
if [[ -z $app_max_requests ]]
then
max_requests=""
else
max_requests=" --max-requests ${app_max_requests} "
fi
if [[ -z $monitor_processes ]]
then
monitor_processes=0
fi
if [[ -z $jormun_cache_items ]]
then
jormun_cache_items=2048
fi
jormungandr_cache2="name=jormungandr,items=${jormun_cache_items}"
if [[ ! -z $gormungandr_url ]] && [[ ! -z $gormungandr_version ]];
then
echo "export GORMUNGANDR_URL=$gormungandr_url" >> /etc/apache2/envvars
echo "export GORMUNGANDR_VERSION=$gormungandr_version" >> /etc/apache2/envvars
fi
# run apache2
service apache2 start
if [ $? == 1 ]
then
echo "Error: failed to start apache2";
exit 1
fi
# run UWSGI
if [ $monitor_processes -eq 1 ]
then
echo "!!!!!!!!!!!!!!!!!!!!! Start Jormungandr with monitoring service !!!!!!!!!!!!!!!!!!!!!"
# JORMUNGANDR_IS_PUBLIC is set to True only for the use of /v1/backends_status
uwsgi --cache2 $jormungandr_cache2 $max_requests --http :9090 --stats :5050 --lazy-apps --file $file & JORMUNGANDR_IS_PUBLIC=True uwsgi --cache2 $monitor_cache2 --http :9091 --lazy-apps --file $file --processes 1 --listen 5
else
echo "!!!!!!!!!!!!!!!!!!!!! Start Jormungandr without monitoring service !!!!!!!!!!!!!!!!!!!!!"
uwsgi --cache2 $jormungandr_cache2 $max_requests --http :9090 --stats :5050 --lazy-apps --file $file
fi
if [ $? == 1 ]
then
echo "Error: Jormungandr was not launched";
exit 1
fi
exec "$@"