2013-09-20 15:55:44 +00:00
|
|
|
import logging
|
2014-01-30 18:32:06 +00:00
|
|
|
import os
|
2013-09-20 15:55:44 +00:00
|
|
|
|
2013-09-30 20:14:48 +00:00
|
|
|
from app import app as application
|
2014-01-31 16:14:07 +00:00
|
|
|
from data.model import db as model_db
|
2013-09-20 15:55:44 +00:00
|
|
|
|
2014-01-30 18:32:06 +00:00
|
|
|
# Initialize logging
|
|
|
|
application.config['LOGGING_CONFIG']()
|
2013-10-25 19:47:34 +00:00
|
|
|
|
2014-01-31 00:48:39 +00:00
|
|
|
# Turn off debug logging for boto
|
|
|
|
logging.getLogger('boto').setLevel(logging.CRITICAL)
|
2013-10-25 19:47:34 +00:00
|
|
|
|
2013-12-30 22:05:27 +00:00
|
|
|
from endpoints.api import api
|
|
|
|
from endpoints.index import index
|
|
|
|
from endpoints.web import web
|
|
|
|
from endpoints.tags import tags
|
|
|
|
from endpoints.registry import registry
|
|
|
|
from endpoints.webhooks import webhooks
|
2014-02-06 18:36:32 +00:00
|
|
|
from endpoints.realtime import realtime
|
2013-09-20 15:55:44 +00:00
|
|
|
|
2013-10-25 19:47:34 +00:00
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
if application.config.get('INCLUDE_TEST_ENDPOINTS', False):
|
|
|
|
logger.debug('Loading test endpoints.')
|
|
|
|
import endpoints.test
|
|
|
|
|
2013-12-30 22:05:27 +00:00
|
|
|
application.register_blueprint(web)
|
|
|
|
application.register_blueprint(index, url_prefix='/v1')
|
|
|
|
application.register_blueprint(tags, url_prefix='/v1')
|
|
|
|
application.register_blueprint(registry, url_prefix='/v1')
|
|
|
|
application.register_blueprint(api, url_prefix='/api')
|
|
|
|
application.register_blueprint(webhooks, url_prefix='/webhooks')
|
2014-02-06 18:36:32 +00:00
|
|
|
application.register_blueprint(realtime, url_prefix='/realtime')
|
2013-12-30 22:05:27 +00:00
|
|
|
|
2014-01-31 01:57:40 +00:00
|
|
|
|
|
|
|
def close_db(exc):
|
2014-01-31 16:14:07 +00:00
|
|
|
db = model_db
|
2014-01-31 01:57:40 +00:00
|
|
|
if not db.is_closed():
|
|
|
|
logger.debug('Disconnecting from database.')
|
|
|
|
db.close()
|
|
|
|
|
|
|
|
application.teardown_request(close_db)
|
|
|
|
|
|
|
|
|
2013-09-30 20:14:48 +00:00
|
|
|
# Remove this for prod config
|
|
|
|
application.debug = True
|
|
|
|
|
2013-10-01 03:54:12 +00:00
|
|
|
if __name__ == '__main__':
|
2013-10-26 20:03:11 +00:00
|
|
|
application.run(port=5000, debug=True, threaded=True, host='0.0.0.0')
|