fix many bugs

This commit is contained in:
zema1
2017-10-31 16:33:25 +08:00
parent f0655ee305
commit aa4240790b
12 changed files with 62 additions and 35 deletions

View File

@@ -10,6 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
import os
from copy import deepcopy
from .custom_settings import *
@@ -20,17 +21,17 @@ else:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Applications
INSTALLED_APPS = (
VENDOR_APPS = (
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'account',
)
LOCAL_APPS = (
'account',
'announcement',
'conf',
'problem',
@@ -38,8 +39,11 @@ INSTALLED_APPS = (
'utils',
'submission',
'options',
'judge',
)
INSTALLED_APPS = VENDOR_APPS + LOCAL_APPS
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
@@ -115,17 +119,16 @@ LOGGING = {
'formatters': {
'standard': {
'format': '%(asctime)s [%(threadName)s:%(thread)d] [%(name)s:%(lineno)d] [%(module)s:%(funcName)s] [%(levelname)s]- %(message)s'}
# 日志格式
},
'handlers': {
'django_error': {
'level': 'DEBUG',
'level': 'WARNING',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(LOG_PATH, 'django.log'),
'formatter': 'standard'
},
'app_info': {
'level': 'DEBUG',
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(LOG_PATH, 'app_info.log'),
'formatter': 'standard'
@@ -137,23 +140,30 @@ LOGGING = {
}
},
'loggers': {
'app_info': {
'handlers': ['app_info', "console"],
'level': 'DEBUG',
'propagate': True
},
'django.request': {
'handlers': ['django_error', 'console'],
'level': 'DEBUG',
'level': 'WARNING',
'propagate': True,
},
'django.server': {
'handlers': ['django_error', 'console'],
'level': 'ERROR',
'propagate': True,
},
'django.db.backends': {
'handlers': ['console'],
'level': 'ERROR',
'handlers': ['django_error', 'console'],
'level': 'WARNING',
'propagate': True,
}
},
},
}
app_logger = {
'handlers': ['app_info', 'console'],
'level': 'DEBUG',
'propagate': False
}
LOGGING["loggers"].update({app: deepcopy(app_logger) for app in LOCAL_APPS})
REST_FRAMEWORK = {
'TEST_REQUEST_DEFAULT_FORMAT': 'json',
'DEFAULT_RENDERER_CLASSES': (
@@ -163,6 +173,7 @@ REST_FRAMEWORK = {
REDIS_URL = "redis://%s:%s" % (REDIS_CONF["host"], REDIS_CONF["port"])
def redis_config(db):
def make_key(key, key_prefix, version):
return key
@@ -175,16 +186,14 @@ def redis_config(db):
"KEY_FUNCTION": make_key
}
CACHES = {
"default": redis_config(db=1)
}
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "default"
CELERY_RESULT_BACKEND = f"{REDIS_URL}/2"
BROKER_URL = f"{REDIS_URL}/3"
CELERY_TASK_SOFT_TIME_LIMIT = CELERY_TASK_TIME_LIMIT = 180