Skip to content

Commit

Permalink
修改oslo版本
Browse files Browse the repository at this point in the history
  • Loading branch information
张悦shadow committed Jul 28, 2015
1 parent e1becb4 commit 1464166
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
6 changes: 3 additions & 3 deletions qg/web/app/wsgiapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ def _gunicorn_run(self):
from gunicorn.app.base import Application
app = self.wsgi_app

class QlibGunicornApp(Application):
class QgGunicornApp(Application):

def init(self, parser, opts, args):
workers = CONF.gunicorn.workers
if workers <= 0:
workers = multiprocessing.cpu_count() * 2 + 1
logger_class = "simple"
if CONF.gunicorn.ignore_healthcheck_accesslog:
logger_class = "qlib.web.glogging.GunicornLogger"
logger_class = "qg.web.glogging.GunicornLogger"
return {
'bind': '{0}:{1}'.format(CONF.web.bind, CONF.web.port),
'config': CONF.gunicorn.config,
Expand All @@ -132,7 +132,7 @@ def load(self):

# NOTE(zhen.pei): 为了不让gunicorn默认匹配sys.argv[1:]
sys.argv = [sys.argv[0]]
QlibGunicornApp().run()
QgGunicornApp().run()

def _set_base_url(self, base_url):
base_url = base_url.strip()
Expand Down
17 changes: 17 additions & 0 deletions qg/web/glogging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
#
# Copyright @ 2014 OPS, Qunar Inc. (qunar.com)
#
# Author: zhen.pei <[email protected]>
#

from gunicorn import glogging


class GunicornLogger(glogging.Logger):

def access(self, resp, req, environ, request_time):
# ignore healthcheck
if environ.get('RAW_URI') == '/healthcheck.html':
return
super(GunicornLogger, self).access(resp, req, environ, request_time)
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
qg.core==0.1.5
oslo.config==1.12.0
qg.core==0.1.6
oslo.config>=2.0.0
Flask==0.10.1

0 comments on commit 1464166

Please sign in to comment.