Skip to content

Instantly share code, notes, and snippets.

@amishurov
Created October 16, 2016 16:48
Show Gist options
  • Save amishurov/dc43599e56afd7e64c0264ef54d2522e to your computer and use it in GitHub Desktop.
Save amishurov/dc43599e56afd7e64c0264ef54d2522e to your computer and use it in GitHub Desktop.
start gunicorn from python
# -*- coding: utf-8 -*-
from gunicorn import util
from gunicorn.app.base import Application
class FixtureApplication(Application):
def __init__(self, options=None):
self.options = options
self.usage = None
self.callable = None
self.prog = ''
self.do_load_config()
def init(self, *args):
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):
return util.import_app("fixture_app:fixture_app")
if __name__ == '__main__':
options = {
'bind': 'localhost:8080',
'loglevel': 'debug'
}
FixtureApplication(options).run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment