def run_server(): # Configure logger configure_logging(config_var='TES_CONFIG_LOG') # Parse app configuration config = parse_app_config(config_var='TES_CONFIG') # Create Connexion app connexion_app = create_connexion_app(config) # Register MongoDB connexion_app.app = register_mongodb(connexion_app.app) # Register error handlers connexion_app = register_error_handlers(connexion_app) # Create Celery app and register background task monitoring service register_task_service(connexion_app.app) # Register OpenAPI specs connexion_app = register_openapi( app=connexion_app, specs=get_conf_type(config, 'api', 'specs', types=(list)), spec_dir=get_conf(config, 'storage', 'spec_dir'), add_security_definitions=True, ) # Enable cross-origin resource sharing enable_cors(connexion_app.app) return connexion_app, config
import os from pro_tes.config.config_parser import get_conf from pro_tes.config.app_config import parse_app_config # Source the WES config for defaults flask_config = parse_app_config(config_var='TES_CONFIG') # Gunicorn number of workers and threads workers = int(os.environ.get('GUNICORN_PROCESSES', '3')) threads = int(os.environ.get('GUNICORN_THREADS', '1')) forwarded_allow_ips = '*' # Gunicorn bind address bind = '{address}:{port}'.format( address=get_conf(flask_config, 'server', 'host'), port=get_conf(flask_config, 'server', 'port'), ) # Source the environment variables for the Gunicorn workers raw_env = [ "TES_CONFIG=%s" % os.environ.get('TES_CONFIG', ''), "RABBIT_HOST=%s" % os.environ.get('RABBIT_HOST', get_conf(flask_config, 'celery', 'broker_host')), "RABBIT_PORT=%s" % os.environ.get('RABBIT_PORT', get_conf(flask_config, 'celery', 'broker_port')), "MONGO_HOST=%s" % os.environ.get('MONGO_HOST', get_conf(flask_config, 'database', 'host')), "MONGO_PORT=%s" % os.environ.get('MONGO_PORT', get_conf(flask_config, 'database', 'port')), "MONGO_DBNAME=%s" % os.environ.get('MONGO_DBNAME', get_conf(flask_config, 'database', 'name')), "MONGO_USERNAME=%s" % os.environ.get('MONGO_USERNAME', ''), "MONGO_PASSWORD=%s" % os.environ.get('MONGO_PASSWORD', '') ]