Bug 1175432 - Make it more obvious if DATABASE_URL is not set

Removes the default value for DATABASE_URL and DATABASE_URL_RO, so that
if either are not set, there is a clearer upfront Django error about
Databases not being configured, rather than timeouts trying to connect
to localhost.

This makes it more obvious when setting up a new instance that the
variables are not present in the environment (and would have avoided
some confusion on Heroku today, when DATABASE_URL was set, but
DATABASE_URL_RO was not) - in exchange for now needing two extra lines
in the puppet config for local testing.
This commit is contained in:
Ed Morley 2015-07-15 16:17:59 +01:00
Родитель 1af312e0cc
Коммит f92065534a
2 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -34,6 +34,8 @@ line {"etc-hosts":
file {"/etc/profile.d/treeherder.sh":
content => "
export DATABASE_URL='mysql://${DB_USER}:${DB_PASS}@localhost/treeherder'
export DATABASE_URL_RO='mysql://${DB_USER}:${DB_PASS}@localhost/treeherder'
export TREEHERDER_DEBUG='1'
export TREEHERDER_DJANGO_SECRET_KEY='${DJANGO_SECRET_KEY}'
"

Просмотреть файл

@ -12,8 +12,6 @@ from treeherder import path
# These settings can all be optionally set via env vars, or in local.py:
DEFAULT_DATABASE_URL = 'mysql://treeherder_user:treeherder_pass@localhost/treeherder'
TREEHERDER_MEMCACHED = os.environ.get("TREEHERDER_MEMCACHED", "127.0.0.1:11211")
TREEHERDER_MEMCACHED_KEY_PREFIX = os.environ.get("TREEHERDER_MEMCACHED_KEY_PREFIX", "treeherder")
@ -373,11 +371,11 @@ INSTALLED_APPS += LOCAL_APPS
TEMPLATE_DEBUG = DEBUG
# The default DB config is extracted from the DATABASE_URL environment variable, and the
# read only config from DATABASE_URL_RO. If those are not set, DEFAULT_DATABASE_URL is used.
# The database config is defined using environment variables of form:
# 'mysql://username:password@host:optional_port/database_name'
DATABASES = {
'default': dj_database_url.config(default=DEFAULT_DATABASE_URL),
'read_only': dj_database_url.config(env='DATABASE_URL_RO', default=DEFAULT_DATABASE_URL)
'default': dj_database_url.config(env='DATABASE_URL'),
'read_only': dj_database_url.config(env='DATABASE_URL_RO')
}
# Setup ssl connection for aws rds.