update settings
This commit is contained in:
@@ -14,14 +14,12 @@ DATABASES = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# For celery
|
||||
REDIS_QUEUE = {
|
||||
REDIS_CONF = {
|
||||
"host": "127.0.0.1",
|
||||
"port": 6379,
|
||||
"db": 4
|
||||
"port": "6379"
|
||||
}
|
||||
|
||||
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
@@ -31,5 +29,3 @@ TEST_CASE_DIR = "/tmp"
|
||||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR, "static"),
|
||||
]
|
||||
|
||||
LOG_PATH = "log/"
|
||||
28
oj/production_settings.py
Normal file
28
oj/production_settings.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
|
||||
|
||||
def get_env(name, default=""):
|
||||
return os.environ.get(name, default)
|
||||
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'HOST': get_env("POSTGRESQL_HOST", "postgresql"),
|
||||
'PORT': get_env("POSTGRESQL_PORT", "5433"),
|
||||
'NAME': get_env("POSTGRESQL_DBNAME"),
|
||||
'USER': get_env("POSTGRESQL_USER"),
|
||||
'PASSWORD': get_env("POSTGRESQL_PASSWORD")
|
||||
}
|
||||
}
|
||||
|
||||
REDIS_CONF = {
|
||||
"host": get_env("REDIS_HOST", "redis"),
|
||||
"port": get_env("REDIS_PORT", "6379")
|
||||
}
|
||||
|
||||
DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
TEST_CASE_DIR = "/test_case"
|
||||
@@ -1,37 +0,0 @@
|
||||
# coding=utf-8
|
||||
import os
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': "oj",
|
||||
'CONN_MAX_AGE': 0.1,
|
||||
'HOST': os.environ["MYSQL_PORT_3306_TCP_ADDR"],
|
||||
'PORT': 3306,
|
||||
'USER': os.environ["MYSQL_ENV_MYSQL_USER"],
|
||||
'PASSWORD': os.environ["MYSQL_ENV_MYSQL_ROOT_PASSWORD"]
|
||||
}
|
||||
}
|
||||
|
||||
REDIS_CACHE = {
|
||||
"host": os.environ["REDIS_PORT_6379_TCP_ADDR"],
|
||||
"port": 6379,
|
||||
"db": 1
|
||||
}
|
||||
|
||||
REDIS_QUEUE = {
|
||||
"host": os.environ["REDIS_PORT_6379_TCP_ADDR"],
|
||||
"port": 6379,
|
||||
"db": 2
|
||||
}
|
||||
|
||||
DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
|
||||
TEST_CASE_DIR = "/test_case"
|
||||
|
||||
LOG_PATH = "log/"
|
||||
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user