Created
October 16, 2016 16:48
-
-
Save amishurov/dc43599e56afd7e64c0264ef54d2522e to your computer and use it in GitHub Desktop.
start gunicorn from python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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