Skip to content

Commit

Permalink
Merge pull request #2435 from DOAJ/feature/instance_config
Browse files Browse the repository at this point in the history
Load instance specific configuration
  • Loading branch information
RK206 authored Dec 3, 2024
2 parents dfda935 + c2e5a78 commit 01a2cc5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ htmlcov/*
# Don't push our dev configs or the secret app configs.
dev.cfg
app.cfg
instance.cfg

# directories of transient stuff that gets created locally
media/*
Expand Down
12 changes: 11 additions & 1 deletion portality/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ def configure_app(app):
a) the settings.py file
b) the <env>.cfg file
c) the local secrets config in app.cfg
d) the ansible-generated instance config
Later imports have precedence, so e.g. app.cfg will override the same setting in production.cfg and settings.py.
instance.cfg is generated by ansible script (server_initial_setup.yml from sysadmin repo)
Later imports have precedence, so e.g. instance.cfg override app.cfg, app.cfg will override the same setting
in production.cfg and settings.py.
"""

# import for settings.py
Expand All @@ -93,6 +97,12 @@ def configure_app(app):
app.config.from_pyfile(config_path)
print('Loaded secrets config from ' + config_path)

# import from instance.cfg
instance_path = os.path.join(proj_root, 'instance.cfg')
if os.path.exists(instance_path):
app.config.from_pyfile(instance_path)
print('Loaded instance specific config from ' + instance_path)


def get_app_env(app):
if not app.config.get('VALID_ENVIRONMENTS'):
Expand Down

0 comments on commit 01a2cc5

Please sign in to comment.