-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
157 lines (142 loc) · 3.31 KB
/
entrypoint.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
set +e
# Script trace mode
if [ "${DEBUG_MODE}" == "true" ]; then
set -o xtrace
fi
cd /home/app/vfzsync
if [ ! -d ./config ]; then
mkdir config
fi
if [ ! -d ./log ]; then
mkdir log
fi
DEFAULT_CONFIG=$(cat <<-END
general:
debug: ${GENERAL_DEBUG}
dryrun: ${GENERAL_DRYRUN}
trace: ${GENERAL_TRACE}
loglevel: ${GENERAL_LOGLEVEL}
interval: ${GENERAL_INTERVAL}
loops: ${GENERAL_LOOPS}
vpoller:
endpoint: ${VPOLLER_ENDPOINT}
vc_host: ${VPOLLER_VC_HOST}
zabbix:
url: ${ZABBIX_URL}
username: ${ZABBIX_USERNAME}
password: ${ZABBIX_PASSWORD}
hostgroup: ${ZABBIX_HOSTGROUP}
template: ${ZABBIX_TEMPLATE}
proxy: ${ZABBIX_PROXY}
command:
url: ${COMMAND_URL}
username: ${COMMAND_USERNAME}
password: ${COMMAND_PASSWORD}
logging:
version: 1
formatters:
simple:
format: '%(asctime)s:%(module)s:%(name)s:%(levelname)s:%(message)s'
default:
format: '[%(asctime)s] %(levelname)s in %(module)s: %(message)s'
handlers:
console:
class: logging.StreamHandler
level: DEBUG
formatter: simple
stream: ext://sys.stderr
file:
class: logging.FileHandler
level: ERROR
formatter: simple
filename: <defined_in_code.log>
wsgi:
class: logging.StreamHandler
stream: ext://flask.logging.wsgi_errors_stream
formatter: simple
logging:
version: 1
formatters:
simple:
format: '%(asctime)s:%(module)s:%(name)s:%(levelname)s:%(message)s'
default:
format: '[%(asctime)s] %(levelname)s in %(module)s: %(message)s'
handlers:
console:
class: logging.StreamHandler
level: DEBUG
formatter: simple
stream: ext://sys.stderr
file:
class: logging.FileHandler
level: ERROR
formatter: simple
filename: <defined_in_code.log>
wsgi:
class: logging.StreamHandler
stream: ext://flask.logging.wsgi_errors_stream
formatter: simple
loggers:
vfzsync:
level: ${GENERAL_LOGLEVEL}
handlers: [file, wsgi]
propagate: no
vfzlib:
level: ${GENERAL_LOGLEVEL}
handlers: [console, file, wsgi]
propagate: no
__main__:
level: ${GENERAL_LOGLEVEL}
handlers: [console, file]
propagate: no
werkzeug:
level: WARN
handlers: [wsgi]
propagate: no
gunicorn:
level: ${GENERAL_LOGLEVEL}
handlers: [wsgi]
propagate: no
gunicorn.access:
level: WARN
handlers: [wsgi]
propagate: no
gunicorn.error:
level: ${GENERAL_LOGLEVEL}
handlers: [wsgi]
propagate: no
pyzabbix:
level: INFO
handlers: [file, wsgi]
propagate: no
requests.packages.urllib3:
level: WARN
handlers: [file, wsgi]
propagate: yes
root:
level: WARN
handlers: [console, file, wsgi]
END
)
if [ ! -f ./config/vfzsync.yaml ]; then
echo "$DEFAULT_CONFIG" > ./config/vfzsync.yaml
fi
MODE=$1
ENV=$2
echo Staring in ${MODE} mode, env ${ENV}
if [ ${MODE} == 'web' ]; then
if [ ${ENV} == 'prod' ]; then
exec gunicorn -b :5000 --access-logfile - --error-logfile - vfz_webapp:app
fi
if [ ${ENV} == 'dev' ]; then
export FLASK_APP=vfz_webapp.py
exec python -m flask run --host=0.0.0.0
fi
fi
if [ ${MODE} == 'script' ]; then
exec python -m vfzsync
fi
if [ ${MODE} == 'debug' ]; then
while true; do sleep 60; done
fi