forked from JeffVandrewJr/patron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_boot.py
30 lines (25 loc) · 832 Bytes
/
docker_boot.py
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
import os
import requests
import time
'''
Some configuration options are loaded from the database,
however the database cannot be loaded until after Flask app creation.
Therefore, some config has to be done by registering the config
functions with @app.before_first_request decorator in the app
factory. The script in this file will continually make GET requests
to LibrePatron until it gets a valid 200 response when a Docker
container boots. This will force those config functions to load upon boot.
'''
def load_config():
while True:
try:
r = requests.get(
'https://' + os.environ.get('VIRTUAL_HOST')
)
if r.status_code == 200:
break
except Exception:
pass
time.sleep(2)
if __name__ == '__main__':
load_config()