Пример #1
0
sys.path.insert(
    0,
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)))

from tools_lib.log import init_log
# 配置全局logging. => 配完PYTHON_PATH,在所有的import前做!!!
init_log(os.path.dirname(os.path.abspath(__file__)))

from tools_lib.transwarp import db
from tools_lib.transwarp.web import WSGIApplication
from model_logics.config import CONFIGS
import rest_api

# init db:
db.create_engine(**CONFIGS.db)

# init wsgi app:
WSGI_APP = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))

# wsgi.add_interceptor(api.user_interceptor)
# wsgi.add_interceptor(api.manage_interceptor)
WSGI_APP.add_module(rest_api)

if __name__ == '__main__':
    WSGI_APP.run(5009, host='0.0.0.0')
else:
    # init log does not work here.
    print "\n@@@ uWSGI @@@\n"
    application = WSGI_APP.get_wsgi_application()
Пример #2
0
#!/usr/bin/env python
# coding:utf-8

"""
A WSGI application entry.
"""
import os

from transwarp.log import init_log
# 配置全局logging. => 配完PYTHON_PATH,在所有的import前做!!!
init_log(os.path.dirname(os.path.abspath(__file__)))

from tools_lib.transwarp import db
from tools_lib.transwarp.web import WSGIApplication
from model_logics.config import CONFIGS
import rest_api

# init db:
db.create_engine(**CONFIGS.db)

# init wsgi app:
WSGI_APP = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))

WSGI_APP.add_module(rest_api)

if __name__ == '__main__':
    WSGI_APP.run(5011, host='0.0.0.0')
else:
    print "\n@@@ uWSGI @@@\n"
    application = WSGI_APP.get_wsgi_application()
Пример #3
0
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)))

from tools_lib.common_util.log import init_log
# === 配置全局logging. ==> 配完PYTHON_PATH,在所有的import前做!!!
init_log(os.path.dirname(os.path.abspath(__file__)))

from mongoengine import connect
from tools_lib.transwarp import db
from tools_lib.transwarp.web import WSGIApplication
from model_logics.config import CONFIGS
import rest_api

# init mysql:
db.create_engine(**CONFIGS.mysql)
# init mongodb: https://jira.mongodb.org/browse/PYTHON-986
connect(host=CONFIGS.mongodb, alias='profile_connection', connect=False)
logging.info("Init mongodb with %s", CONFIGS.mongodb)

# init wsgi app:
wsgi_app = WSGIApplication(os.path.dirname(os.path.abspath(__file__)))

wsgi_app.add_module(rest_api)

if __name__ == '__main__':
    wsgi_app.run(6003, host='0.0.0.0')
else:
    # init log does not work here.
    print("\n@@@ uWSGI @@@\n")
    application = wsgi_app.get_wsgi_application()