forked from fedora-python/portingdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wsgi.py
44 lines (34 loc) · 1.13 KB
/
wsgi.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
import os
import logging
from sqlalchemy import create_engine
from dogpile.cache import make_region
from portingdb import load
from portingdb import htmlreport
level = logging.INFO
logging.basicConfig(level=level)
logging.getLogger('sqlalchemy.engine').setLevel(level)
sqlite_path = os.path.join(os.environ['OPENSHIFT_TMP_DIR'], 'portingdb.sqlite')
db_url = 'sqlite:///' + sqlite_path
cache_config = {
'backend': 'dogpile.cache.redis',
'expiration_time': 3600, # 1h
'arguments': {
'host': os.environ['OPENSHIFT_REDIS_HOST'],
'port': os.environ['OPENSHIFT_REDIS_PORT'],
'password': os.environ['REDIS_PASSWORD'],
'db': 0,
'redis_expiration_time': 3600 + 600, # 1h 10min
'distributed_lock': True
}
}
application = htmlreport.create_app(db_url=db_url, cache_config=cache_config)
import pprint
pprint.pprint(os.environ)
# For testing only
if __name__ == '__main__':
from wsgiref.simple_server import make_server
httpd = make_server('localhost', 8051, application)
# Wait for requests, stop with Ctrl+C.
while True:
httpd.handle_request()