Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc stuff for a multi-server universe #61

Merged
merged 8 commits into from
Oct 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions django_www/common_settings.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
BASE = Path(__file__).absolute().ancestor(2) BASE = Path(__file__).absolute().ancestor(2)


# Far too clever trick to know if we're running on the deployment server. # Far too clever trick to know if we're running on the deployment server.
PRODUCTION = ('DJANGOPROJECT_DEBUG' not in os.environ) and ("djangoproject" in platform.node()) PRODUCTION = ('DJANGOPROJECT_DEBUG' not in os.environ)


# It's a secret to everybody # It's a secret to everybody
with open(BASE.parent.child('secrets.json')) as handle: with open(BASE.child('secrets.json')) as handle:
SECRETS = json.load(handle) SECRETS = json.load(handle)




Expand All @@ -30,7 +30,7 @@
CACHES = { CACHES = {
'default': { 'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211', 'LOCATION': SECRETS.get('memcached_host', '127.0.0.1:11211'),
} if PRODUCTION else { } if PRODUCTION else {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache' 'BACKEND': 'django.core.cache.backends.dummy.DummyCache'
}, },
Expand All @@ -46,7 +46,9 @@
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'djangoproject', 'NAME': 'djangoproject',
'USER': 'djangoproject' 'USER': 'djangoproject',
'HOST': SECRETS.get('db_host', 'localhost'),
'PASSWORD': SECRETS.get('db_password', ''),
}, },
} }


Expand Down Expand Up @@ -90,16 +92,14 @@
} }
} }
if PRODUCTION: if PRODUCTION:
LOGGING["handlers"]["logfile"] = { LOGGING["handlers"]["syslog"] = {
"formatter": "full", "formatter": "full",
"level": "DEBUG", "level": "DEBUG",
"class": "logging.handlers.TimedRotatingFileHandler", "class": "logging.handlers.SysLogHandler",
"filename": "/var/log/django_website/website.log", "address": "/dev/log",
"when": "D", "facility": "local4",
"interval": 7,
"backupCount": 5,
} }
LOGGING["loggers"]["django.request"]["handlers"].append("logfile") LOGGING["loggers"]["django.request"]["handlers"].append("syslog")




MANAGERS = ( MANAGERS = (
Expand Down
6 changes: 4 additions & 2 deletions django_www/settings.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@


### Django settings ### Django settings


ALLOWED_HOSTS = ['www.djangoproject.com', 'djangoproject.com'] ALLOWED_HOSTS = ['www.djangoproject.com', 'djangoproject.com'] + SECRETS.get('allowed_hosts', [])


CACHE_MIDDLEWARE_KEY_PREFIX = 'djangoproject' CACHE_MIDDLEWARE_KEY_PREFIX = 'djangoproject'


DATABASES['trac'] = { DATABASES['trac'] = {
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'code.djangoproject', 'NAME': 'code.djangoproject',
'USER': 'code.djangoproject' 'USER': 'code.djangoproject',
'HOST': SECRETS.get('trac_db_host', 'localhost'),
'PASSWORD': SECRETS.get('trac_db_password', ''),
} }


DATABASE_ROUTERS = ['tracdb.db_router.TracRouter'] DATABASE_ROUTERS = ['tracdb.db_router.TracRouter']
Expand Down