Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #61 from coderanger/master

Misc stuff for a multi-server universe
  • Loading branch information...
commit 05932f914f1e88c65198f6ab4d42be8b273bd7fd 2 parents 1be2165 + 5d866a5
Jacob Kaplan-Moss jacobian authored
Showing with 15 additions and 13 deletions.
  1. +11 −11 django_www/common_settings.py
  2. +4 −2 django_www/settings.py
22 django_www/common_settings.py
View
@@ -13,10 +13,10 @@
BASE = Path(__file__).absolute().ancestor(2)
# 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
-with open(BASE.parent.child('secrets.json')) as handle:
+with open(BASE.child('secrets.json')) as handle:
SECRETS = json.load(handle)
@@ -30,7 +30,7 @@
CACHES = {
'default': {
'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 {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache'
},
@@ -46,7 +46,9 @@
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'djangoproject',
- 'USER': 'djangoproject'
+ 'USER': 'djangoproject',
+ 'HOST': SECRETS.get('db_host', 'localhost'),
+ 'PASSWORD': SECRETS.get('db_password', ''),
},
}
@@ -90,16 +92,14 @@
}
}
if PRODUCTION:
- LOGGING["handlers"]["logfile"] = {
+ LOGGING["handlers"]["syslog"] = {
"formatter": "full",
"level": "DEBUG",
- "class": "logging.handlers.TimedRotatingFileHandler",
- "filename": "/var/log/django_website/website.log",
- "when": "D",
- "interval": 7,
- "backupCount": 5,
+ "class": "logging.handlers.SysLogHandler",
+ "address": "/dev/log",
+ "facility": "local4",
}
- LOGGING["loggers"]["django.request"]["handlers"].append("logfile")
+ LOGGING["loggers"]["django.request"]["handlers"].append("syslog")
MANAGERS = (
6 django_www/settings.py
View
@@ -5,14 +5,16 @@
### 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'
DATABASES['trac'] = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'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']
Please sign in to comment.
Something went wrong with that request. Please try again.