Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Misc stuff for a multi-server universe #61

Merged
merged 8 commits into from

3 participants

Noah Kantrowitz Aymeric Augustin Jacob Kaplan-Moss
Noah Kantrowitz

No description provided.

Jacob Kaplan-Moss jacobian merged commit 05932f9 into from
Aymeric Augustin

That breaks './manage.py runserver' in dev, not cool :-/

Just have to set the relevant env var and it should work fine.

Owner

That's what I did. I understand the difficulty of running in dev mode by default in dev and never in prod...

@aaugustin I think its just historical cruft, can probably be changed to default to dev mode but I defer to @jacobian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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']
Something went wrong with that request. Please try again.