Merge "Use gunicorn instead of werkzeug"
This commit is contained in:
commit
7e2216219e
@ -11,4 +11,4 @@ python-dateutil==2.5.3
|
||||
pytz==2016.7
|
||||
requests==2.11.1
|
||||
six==1.10.0
|
||||
Werkzeug==0.11.11
|
||||
gunicorn==19.6.0
|
||||
|
@ -52,4 +52,4 @@ source-dir = releasenotes/source
|
||||
|
||||
[entry_points]
|
||||
console_scripts =
|
||||
valence = valence.run:main
|
||||
valence = valence.cmd.api:main
|
||||
|
0
valence/cmd/__init__.py
Normal file
0
valence/cmd/__init__.py
Normal file
@ -14,16 +14,42 @@
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
|
||||
import gunicorn.app.base
|
||||
from gunicorn.six import iteritems
|
||||
|
||||
from valence.api.route import app as application
|
||||
from valence import config as cfg
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class StandaloneApplication(gunicorn.app.base.BaseApplication):
|
||||
|
||||
def __init__(self, app, options=None):
|
||||
self.options = options or {}
|
||||
self.application = app
|
||||
super(StandaloneApplication, self).__init__()
|
||||
|
||||
def load_config(self):
|
||||
config = dict([(key, value) for key, value in iteritems(self.options)
|
||||
if key in self.cfg.settings and value is not None])
|
||||
for key, value in iteritems(config):
|
||||
self.cfg.set(key.lower(), value)
|
||||
|
||||
def load(self):
|
||||
return self.application
|
||||
|
||||
|
||||
def main():
|
||||
application.run(host=cfg.bind_host, port=cfg.bind_port, debug=cfg.debug)
|
||||
options = {
|
||||
'bind': '%s:%s' % (cfg.bind_host, cfg.bind_port)
|
||||
}
|
||||
StandaloneApplication(application, options).run()
|
||||
LOG.info(("Valence Server on http://%(host)s:%(port)s"),
|
||||
{'host': cfg.bind_host, 'port': cfg.bind_port})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user