-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwsgi.py
56 lines (43 loc) · 1.25 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
45
46
47
48
49
50
51
52
53
54
55
56
"""gunicorn WSGI server configuration."""
from multiprocessing import cpu_count
from gunicorn.app.base import Application
from gunicorn import util
def max_workers():
return cpu_count()
class runDHBox(Application):
'''
Custom Gunicorn Application
'''
def __init__(self, options={}):
'''__init__ method
Load the base config and assign some core attributes.
'''
self.usage = None
self.callable = None
self.options = options
self.do_load_config()
def init(self, *args):
'''init method
Takes our custom options from self.options and creates a config
dict which specifies custom settings.
'''
cfg = {}
for k, v in self.options.items():
if k.lower() in self.cfg.settings and v is not None:
cfg[k.lower()] = v
return cfg
def load(self):
'''load method
Imports our application and returns it to be run.
'''
return util.import_app("dhbox:app")
def prog(self):
pass
if __name__ == "__main__":
options = {
'bind' : '0.0.0.0:80',
'max_requests' : 1000,
'worker_class' : 'gevent',
'workers' : max_workers(),
}
runDHBox(options).run()