production.py 3.48 KB
Newer Older
1
2
3
4
5
6
7
8
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# override all the things for the production environment
from __future__ import absolute_import
import os
from .settings import *
from . import secret

DEBUG = False
Daniel W Bond's avatar
Daniel W Bond committed
9
TEMPLATE_DEBUG = False
10
ALLOWED_HOSTS = ['roomlist.gmu.edu']
11
12
13
14
15
16

PIWIK_DOMAIN_PATH = 'https://piwik.srct.gmu.edu/'
PIWIK_SITE_ID = 4

DATABASES = {
    'default': {
17
        'ENGINE': 'django.db.backends.mysql',
18
19
        'NAME': secret.DB_NAME,
        'USER': secret.DB_USER,
20
        'PASSWORD': secret.DB_PASSWORD,
21
22
        'HOST': secret.DB_HOST,
        'PORT': secret.DB_PORT,
23
24
25
26
27
28
29
30
31
32
33
34
35
    }
}

# example.com is 1
# roomlist.srct.gmu.edu is 2
# roomlist.gmu.edu is 3
SITE_ID = 3

# where the static files are being hosted from
STATIC_ROOT = '/srv/roomlist/static'
# can haz ssl certs
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'

36
# use redis cache when not in local development
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
CACHES = {
    'default': {
        'BACKEND': 'redis_cache.RedisCache',
        # configure to redis port
        'LOCATION': 'localhost:6379',
     },
}

# need to configure ADMINS email so that ERROR level logs (500 level exceptions)
# can be sent out

# https://docs.djangoproject.com/en/1.7/topics/logging/
# https://docs.djangoproject.com/en/1.7/howto/error-reporting/
# https://docs.python.org/2/library/logging.config.html#configuration-dictionary-schema

52
53
54
55
56
# use the *real*, non development email backend
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

# the email address that error messages come from; sent to admins
SERVER_EMAIL = ''
57
58
ADMINS = (('Roomlist Devs', 'roomlist@lists.srct.gmu.edu'),
          ('SRCT Execs', 'srct@gmu.edu'),)
59
60

# logging into the mail server
61
EMAIL_HOST = 'localhost'
62
EMAIL_PORT = 25
63
64
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = secret.EMAIL_HOST_PASSWORD
65
# includes implicit TLS
66
67
68
69
EMAIL_USE_SSL = False

LOGGING = {
    'version': 1,
70
71
    # the ones the print everything out to the terminal
    # and the ones that email on SuspiciousOperation occurrences
72
    'disable_existing_loggers': False,
73
74
75
76
77
78
79
80
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s',
        },
        'simple': {
            'format': '%(levelname)s %(asctime)s %(message)s'
        },
    },
81
82
    'handlers': {
        'file': {
83
            'level': 'WARNING',
84
            'class': 'logging.FileHandler',
85
            'formatter': 'verbose',
86
87
            # make sure to change this to the proper path, and one that
            # can be written to
88
            'filename': '/srv/roomlist/debug.log',
89
90
91
92
93
94
95
96
97
98
99
        },
        # 'mail_admins' by default does not include a traceback attachment
        # setting 'include_html' to True will attach an html traceback file to the email
        # you can also set an additional 'email_backend' arg to a custom email handler (e.g. SES)
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler',
            'include_html': True,
        },
    },
    'loggers': {
100
101
102
        # logs request errors
        # 5XX responses are raised as ERROR messages
        # 4XX responses are raised as WARNING messages
103
        'django.request': {
104
105
106
107
108
            'handlers': ['file', 'mail_admins'],
            'propagate': True,
        },
        'django.template': {
            'handlers': ['file',],
109
110
111
112
113
114
            'propagate': True,
        },
    # django's default loggers send request and security messages at the ERROR
    # or CRITICAL level to the AdminEmailHandler via mail_admins
    },
}