Add high performance gunicorn based wsgi wrapper
Also add pymysql to requirements so fully evented mysql queries can happen.
This commit is contained in:
parent
3070e1805a
commit
d346d4dbf2
94
quark/gunicorn_server.py
Normal file
94
quark/gunicorn_server.py
Normal file
@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
|
||||
from gunicorn.app import base
|
||||
from gunicorn import config as gconfig
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.common import config
|
||||
from neutron.common import legacy
|
||||
from neutron.common import utils
|
||||
from neutron.openstack.common import gettextutils
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron import service # noqa For api_workers config value
|
||||
|
||||
|
||||
options = [
|
||||
cfg.StringOpt('access_log',
|
||||
default='/var/log/neutron/http_access.log',
|
||||
help='The Access log file to write to.'),
|
||||
cfg.StringOpt('error_log',
|
||||
default='/var/log/neutron/http_error.log',
|
||||
help='The Error log file to write to.'),
|
||||
cfg.StringOpt('worker_class',
|
||||
default='eventlet',
|
||||
help='The type of workers to use.'),
|
||||
cfg.IntOpt('limit_request_line',
|
||||
default=0,
|
||||
help='The maximum size of HTTP request line in bytes.'),
|
||||
cfg.StringOpt('loglevel',
|
||||
default='debug',
|
||||
help='The granularity of Error log outputs.'),
|
||||
]
|
||||
cfg.CONF.register_opts(options, 'gunicorn')
|
||||
|
||||
|
||||
gettextutils.install('neutron', lazy=True)
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Neutron(base.Application):
|
||||
def init(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def load_config(self):
|
||||
self.cfg = gconfig.Config(self.usage, prog=self.prog)
|
||||
settings = {'bind': '%s:%s' % (cfg.CONF.bind_host, cfg.CONF.bind_port),
|
||||
'workers': cfg.CONF.api_workers,
|
||||
'worker_class': cfg.CONF.worker_class,
|
||||
'proc_name': 'neutron-server',
|
||||
'accesslog': cfg.CONF.access_log,
|
||||
'errorlog': cfg.CONF.error_log,
|
||||
'limit_request_line': cfg.CONF.limit_request_line,
|
||||
'loglevel': cfg.CONF.loglevel,
|
||||
'access_log_format': ' '.join(('%(h)s',
|
||||
'%(l)s',
|
||||
'%(u)s',
|
||||
'%(t)s',
|
||||
'"%(r)s"',
|
||||
'%(s)s',
|
||||
'%(b)s',
|
||||
'"%(f)s"',
|
||||
'"%(a)s"',
|
||||
'%(T)s',
|
||||
'%(D)s',)),
|
||||
}
|
||||
|
||||
for k, v in settings.iteritems():
|
||||
self.cfg.set(k.lower(), v)
|
||||
|
||||
def load(self):
|
||||
return config.load_paste_app(app_name=self.prog)
|
||||
|
||||
def run(self):
|
||||
base.Arbiter(self).run()
|
||||
|
||||
|
||||
def main():
|
||||
config.parse(sys.argv[1:])
|
||||
if not cfg.CONF.config_file:
|
||||
sys.exit(_("ERROR: Unable to find configuration file via the default"
|
||||
" search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and"
|
||||
" the '--config-file' option!"))
|
||||
|
||||
config.setup_logging(cfg.CONF)
|
||||
legacy.modernize_quantum_config(cfg.CONF)
|
||||
utils.log_opt_values(LOG)
|
||||
|
||||
neutron_api = Neutron(prog='neutron')
|
||||
neutron_api.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -5,6 +5,8 @@ zope.sqlalchemy
|
||||
mysql-python
|
||||
http://tarballs.openstack.org/neutron/neutron-master.tar.gz#egg=neutron
|
||||
aiclib
|
||||
gunicorn
|
||||
pymysql
|
||||
|
||||
# NOTE(jkoelker) not technically required, but something has to commit
|
||||
# the transactions. in the future this should be the
|
||||
|
Loading…
x
Reference in New Issue
Block a user