blob: e56bd043a40c3d0797d366ce69f9abba28d6a22f [file] [log] [blame]
import os
import gunicorn.app.base
from django.core.wsgi import get_wsgi_application
class StandaloneApplication(gunicorn.app.base.BaseApplication):
def __init__(self, app, options=None):
self.options = options or {}
self.application = app
super().__init__()
def load_config(self):
config = {key: value for key, value in self.options.items()
if key in self.cfg.settings and value is not None}
for key, value in config.items():
self.cfg.set(key.lower(), value)
def load(self):
return self.application
def main():
options = {
'bind': os.environ.get('BIND_ADDR', '127.0.0.1:8080'),
'workers': int(os.environ.get("GUNICORN_WORKERS", "4")),
'capture_output': True,
'disable_redirect_access_to_syslog': True,
'accesslog': '-',
'errorlog': '-',
}
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
application = get_wsgi_application()
StandaloneApplication(application, options).run()
if __name__ == '__main__':
main()