summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJing Lu <lvjing5@huawei.com>2017-02-10 06:19:21 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-02-10 06:19:21 +0000
commit67427f9b082a540f22f748eb1a0075d93407f77b (patch)
treeb13e8be0f9078887c5903fdeee0a35c1609e8e89 /api
parent1787d1f400118de3f6bd60bc968cea39b181923e (diff)
parent96a752b948be4ec94f5fb6d6ce38d81f05c235a7 (diff)
Merge "uwsgi: move init_db to uwsgi entry point"
Diffstat (limited to 'api')
-rw-r--r--api/server.py11
-rw-r--r--api/yardstick.ini2
2 files changed, 9 insertions, 4 deletions
diff --git a/api/server.py b/api/server.py
index be7963481..1d42feffb 100644
--- a/api/server.py
+++ b/api/server.py
@@ -10,7 +10,6 @@ from __future__ import absolute_import
import inspect
import logging
-from functools import reduce
from six.moves import filter
from flasgger import Swagger
@@ -38,6 +37,10 @@ def shutdown_session(exception=None):
db_session.remove()
+for u in urlpatterns:
+ api.add_resource(u.resource, u.url, endpoint=u.endpoint)
+
+
def init_db():
def func(a):
try:
@@ -52,8 +55,10 @@ def init_db():
Base.metadata.create_all(bind=engine)
-reduce(lambda a, b: a.add_resource(b.resource, b.url,
- endpoint=b.endpoint) or a, urlpatterns, api)
+def app_wrapper(*args, **kwargs):
+ init_db()
+ return app(*args, **kwargs)
+
if __name__ == '__main__':
_init_logging()
diff --git a/api/yardstick.ini b/api/yardstick.ini
index 2ba881fc1..d2e8956e2 100644
--- a/api/yardstick.ini
+++ b/api/yardstick.ini
@@ -9,7 +9,7 @@ threads = 5
async = true
max-requests = 5000
chmod-socket = 666
-callable = app
+callable = app_wrapper
enable-threads = true
close-on-exec = 1
daemonize= /var/log/yardstick/uwsgi.log