-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.sh
executable file
·56 lines (47 loc) · 995 Bytes
/
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
#!/bin/bash
command=$1
env=$2
worker=$3
function rep_ok(){
echo -e '\e[32m'$1'\e[m'
}
function rep_warn(){
echo -e '\e[1;33mWARNING: '$1'\e[m'
}
function rep_die(){
echo -e '\e[1;31mWARNING: '$1'\e[m'
exit
}
function run_gunicorn(){
apphost=$1
port=$2
worker=$3
if [[ -z $1 ]]; then
rep_warn "Using Default Host"
apphost=localhost
fi
if [[ -z $2 ]]; then
rep_warn "Using Default Port"
port=5000
fi
if [[ -z $3 ]]; then
rep_warn "Using Default Worker"
worker=2
fi
gunicorn production:app -b $apphost:$port -w $worker
}
if [ $command = 'server' ]
then
if [ $env = 'production' ]
then
rep_ok 'STARTING | SERVER'
run_gunicorn $APP_HOST $APP_PORT $worker
elif [ $env = 'development' ]
then
python3 manage.py server
else
rep_die '[env] : production | development'
fi
else
rep_die 'USAGE : ./run.sh server [env].'
fi