diff options
author | Jing Lu <lvjing5@huawei.com> | 2017-02-10 06:19:21 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-02-10 06:19:21 +0000 |
commit | 67427f9b082a540f22f748eb1a0075d93407f77b (patch) | |
tree | b13e8be0f9078887c5903fdeee0a35c1609e8e89 /api/server.py | |
parent | 1787d1f400118de3f6bd60bc968cea39b181923e (diff) | |
parent | 96a752b948be4ec94f5fb6d6ce38d81f05c235a7 (diff) |
Merge "uwsgi: move init_db to uwsgi entry point"
Diffstat (limited to 'api/server.py')
-rw-r--r-- | api/server.py | 11 |
1 files changed, 8 insertions, 3 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() |