Changeset 096625e
- Timestamp:
- Apr 6, 2020, 4:37:59 PM (7 years ago)
- Branches:
- debian/bullseye, master
- Children:
- 78abfaa
- Parents:
- 02b893b
- Location:
- src/mapservice
- Files:
-
- 1 added
- 4 edited
-
codegen/templates/__main__.mustache (modified) (1 diff)
-
src/server_impl/CeleryWorker.py (modified) (2 diffs)
-
src/server_impl/Config.py (modified) (1 diff)
-
src/server_impl/__init__.py (modified) (3 diffs)
-
src/server_impl/tests/test_config.py (added)
Legend:
- Unmodified
- Added
- Removed
-
src/mapservice/codegen/templates/__main__.mustache
r02b893b r096625e 6 6 {{/supportPython2}} 7 7 8 from {{packageName}}.server_impl import app, application, mail, celery, setup_app 8 from {{packageName}}.server_impl import app, application, mail, celery, setup_app, config_object 9 9 10 10 def main(): 11 setup_app('{{appName}}', 'DevelopmentConfig')11 setup_app('{{appName}}', config_object) 12 12 app.run(host=application.config.get("HOST", "localhost"), port=application.config.get("PORT", {{serverPort}})) 13 13 -
src/mapservice/src/server_impl/CeleryWorker.py
r02b893b r096625e 19 19 from sqlalchemy import event 20 20 21 from . import config , app, application, celery, setup_app21 from . import config_object, app, application, celery, setup_app 22 22 from .database.Model import db 23 23 from .tasks import tasks … … 59 59 return celery_app 60 60 61 setup_app('GNUBoat Celery Worker', 'DevelopmentConfig')61 setup_app('GNUBoat Celery Worker', config_object) 62 62 setup_celery(application, celery) -
src/mapservice/src/server_impl/Config.py
r02b893b r096625e 19 19 from pathlib import Path 20 20 import os 21 import yaml 22 23 def load_from_file(config_file): 24 config_from_file = yaml.safe_load(open(config_file)) 25 config = Config() 26 27 for entry in config_from_file: 28 setattr(config, entry, config_from_file[entry]) 29 30 return config 21 31 22 32 class Config(object): -
src/mapservice/src/server_impl/__init__.py
r02b893b r096625e 29 29 from .ValidatorWorkaround import ValidatorWorkaround 30 30 31 def load_config_object(config_name): 32 return import_string('openapi_server.server_impl.Config.{}Config'.format(config_name)) 33 31 34 # determine requested configuration 35 config_file = '/etc/gnuboat/mapservice.conf' 32 36 if 'FLASK_ENV' in os.environ and os.environ['FLASK_ENV']: 33 config_name = os.environ['FLASK_ENV'].title() 37 config_object = load_config_object(os.environ['FLASK_ENV'].title()) 38 elif os.path.isfile(config_file): 39 from . import Config as configure 40 config_object = configure.load_from_file(config_file) 34 41 else: 35 config_name = 'Production' 36 config_name = 'openapi_server.server_impl.Config.{}Config'.format(config_name) 37 config = import_string(config_name) 42 config_object = load_config_object('Production') 38 43 39 44 app = connexion.App(__name__, specification_dir='../openapi/') … … 41 46 CORS(application) 42 47 mail = Mail() 43 celery = Celery(__name__, broker=config .CELERY_BROKER_URL)48 celery = Celery(__name__, broker=config_object.CELERY_BROKER_URL) 44 49 45 50 @application.before_first_request … … 61 66 return render_template('index.html') 62 67 63 def setup_app(app_name, config _name="Config"):68 def setup_app(app_name, config): 64 69 application.json_encoder = encoder.JSONEncoder 65 70 app.add_api('openapi.yaml', arguments={'title': app_name}, validate_responses=True, strict_validation=True, validator_map={'response': ValidatorWorkaround})
Note:
See TracChangeset
for help on using the changeset viewer.
