-
Notifications
You must be signed in to change notification settings - Fork 17
Configuration
Angel Rey edited this page Dec 23, 2020
·
1 revision
We follow a common pattern used by many big projects, we have three levels of config:
- codebase-wide config defaults (
core/oddslingers/settings.py
) - environment-specific config (
env/dev.env
,env/prod.env
, etc.) - machine-specific config (
env/secrets.env
and/or environment variables)
Machine-specific settings can override the environment-specific settings.
Both environment-specific and machine-specific override the defaults in settings.py
.
First identify who you want the new setting to apply to. Do you want to change the setting for:
- Only for one run (e.g. for quickly testing something): set an environment variable
- Persistently but only on your own machine, and no one else's: Edit:
env/secrets.env
- Persistently for all dev users of the codebase? Edit:
env/dev.env
- Persistently but only on prod or beta? Edit:
env/prod.env
orenv/beta.env
- CircleCI builds only? Edit:
env/ci.env
- Everyone? Edit: all instances of the setting in
env/*.env
first!!, then afterwards change the default incore/oddslingers/settings.py
- Environment variables (you can set these with
export name=val
in bash,set -x name val
in fish, orenv name=val ./manage.py command_to_run
) -
env/secrets.env
, this is the proper location for machine-specific settings like DB passwords or local config overrides -
env/{ODDSLINGERS_ENV}.env
, e.g. if you're on devenv/dev.env
, this file is only for defaults, don't modify it unless you want add the change for everyone -
core/oddslingers/settings.py
, this is the main python settings file with all the settings, everything here is overridden from the settings above
If you need to inspect the source of the config loaded system, see these areas:
- general process settings:
etc/supervisord/*.conf
- nginx settings:
etc/nginx/conf.d/*.conf
- django settings: middle section of
core/settings.py
:import_env_file(...)