update settings

This commit is contained in:
zema1
2017-10-23 10:47:26 +08:00
parent 5d03ec5aab
commit 1b0952cd0d
10 changed files with 233 additions and 82 deletions

View File

@@ -1,8 +1,7 @@
# coding=utf-8
"""
Django settings for oj project.
Generated by 'django-admin startproject' using Django 1.8.
Generated by 'django-admin startproject' using Django 1.11.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
@@ -10,27 +9,19 @@ https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from .custom_settings import *
# 判断运行环境
ENV = os.environ.get("oj_env", "local")
if ENV == "local":
from .local_settings import *
elif ENV == "server":
from .server_settings import *
if os.environ.get("NODE_ENV") == "production":
from .production_settings import *
else:
from .dev_settings import *
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# Application definition
# Applications
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.sessions',
@@ -117,6 +108,7 @@ USE_TZ = True
STATIC_URL = '/static/'
AUTH_USER_MODEL = 'account.User'
LOG_PATH = "log/"
LOGGING = {
'version': 1,
@@ -170,9 +162,7 @@ REST_FRAMEWORK = {
)
}
REDIS_URL = "redis://127.0.0.1:6379"
REDIS_URL = "redis://%s:%s" % (REDIS_CONF["host"], REDIS_CONF["port"])
def redis_config(db):
def make_key(key, key_prefix, version):
@@ -191,23 +181,14 @@ CACHES = {
}
CELERY_RESULT_BACKEND = CELERY_BROKER_URL = f"{REDIS_URL}/2"
CELERY_TASK_SOFT_TIME_LIMIT = CELERY_TASK_TIME_LIMIT = 180
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "default"
# For celery
REDIS_QUEUE = {
"host": "127.0.0.1",
"port": 6379,
"db": 4
}
# for celery
BROKER_URL = 'redis://%s:%s/%s' % (REDIS_QUEUE["host"], str(REDIS_QUEUE["port"]), str(REDIS_QUEUE["db"]))
CELERY_RESULT_BACKEND = f"{REDIS_URL}/2"
BROKER_URL = f"{REDIS_URL}/3"
CELERY_TASK_SOFT_TIME_LIMIT = CELERY_TASK_TIME_LIMIT = 180
CELERY_ACCEPT_CONTENT = ["json"]
CELERY_TASK_SERIALIZER = "json"