修改配置文件方便区分不同的开发环境

This commit is contained in:
virusdefender 2015-09-14 18:20:36 +08:00
parent 7febab2f1a
commit c648e0008f
7 changed files with 33 additions and 39 deletions

3
.gitignore vendored
View File

@ -62,4 +62,5 @@ static/src/upload_image/*
build.txt build.txt
tmp/ tmp/
test_case/ test_case/
release/ release/
upload/

View File

@ -1,6 +1,6 @@
FROM python:2.7 FROM python:2.7
ENV PYTHONBUFFERED 1 ENV PYTHONBUFFERED 1
RUN mkdir -p /code/log /code/test_case RUN mkdir -p /code/log /code/test_case /code/upload
WORKDIR /code WORKDIR /code
ADD requirements.txt /code/ ADD requirements.txt /code/
RUN pip install -r requirements.txt RUN pip install -r requirements.txt

View File

@ -1,4 +1,5 @@
# coding=utf-8 # coding=utf-8
import os
# 单个判题端最多同时运行的程序个数因为判题端会同时运行多组测试数据比如一共有5组测试数据 # 单个判题端最多同时运行的程序个数因为判题端会同时运行多组测试数据比如一共有5组测试数据
# 如果MAX_RUNNING_NUMBER大于等于5那么这5组数据就会同时进行评测然后返回结果。 # 如果MAX_RUNNING_NUMBER大于等于5那么这5组数据就会同时进行评测然后返回结果。
# 如果MAX_RUNNING_NUMBER小于5为3那么就会同时运行前三组测试数据然后再运行后两组数据 # 如果MAX_RUNNING_NUMBER小于5为3那么就会同时运行前三组测试数据然后再运行后两组数据
@ -14,12 +15,10 @@ lrun_gid = 1002
# judger工作目录 # judger工作目录
judger_workspace = "/var/judger/" judger_workspace = "/var/judger/"
# 这个是在docker 中访问数据库 ip 不一定和web服务器还有celery的一样
submission_db = { submission_db = {
"host": "192.168.42.1", "host": os.environ.get("MYSQL_PORT_3306_TCP_ADDR", "127.0.0.1"),
"port": 3306, "port": 3306,
"db": "oj_submission", "db": "oj_submission",
"user": "root", "user": "root",
"password": "mypwd" "password": os.environ.get("MYSQL_ENV_MYSQL_ROOT_PASSWORD", "root")
} }

View File

@ -3,10 +3,6 @@ import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# 下面是需要自己修改的
LOG_PATH = "log/"
# 注意这是web 服务器访问的地址,判题端访问的地址不一定一样,因为可能不在一台机器上 # 注意这是web 服务器访问的地址,判题端访问的地址不一定一样,因为可能不在一台机器上
DATABASES = { DATABASES = {
'default': { 'default': {
@ -17,11 +13,11 @@ DATABASES = {
'submission': { 'submission': {
'NAME': 'oj_submission', 'NAME': 'oj_submission',
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
'HOST': "121.42.32.129", 'CONN_MAX_AGE': 0.1,
'HOST': "127.0.0.1",
'PORT': 3306, 'PORT': 3306,
'USER': 'root', 'USER': 'root',
'PASSWORD': 'mypwd', 'PASSWORD': 'root',
'CONN_MAX_AGE': 0.1,
} }
} }
@ -33,13 +29,11 @@ REDIS_CACHE = {
DEBUG = True DEBUG = True
# 同理 这是 web 服务器的上传路径
TEST_CASE_DIR = os.path.join(BASE_DIR, 'test_case/')
ALLOWED_HOSTS = [] ALLOWED_HOSTS = []
IMAGE_UPLOAD_DIR = os.path.join(BASE_DIR, 'static/src/upload_image/') # 在 debug 关闭的情况下,静态文件不是有 django runserver 来处理的,应该由 nginx 返回
# 在 debug 开启的情况下django 会在下面两个文件夹中寻找对应的静态文件。
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static/src/")] STATICFILES_DIRS = [os.path.join(BASE_DIR, "static/src/"), BASE_DIR]
# 模板文件夹
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'template/src/')] TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'template/src/')]

View File

@ -3,47 +3,41 @@ import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# 下面是需要自己修改的
LOG_PATH = "/var/log/oj/"
# 注意这是web 服务器访问的地址,判题端访问的地址不一定一样,因为可能不在一台机器上 # 注意这是web 服务器访问的地址,判题端访问的地址不一定一样,因为可能不在一台机器上
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
'NAME': "oj", 'NAME': "oj",
'CONN_MAX_AGE': 0.1, 'CONN_MAX_AGE': 0.1,
'HOST': '127.0.0.1', 'HOST': os.environ.get("MYSQL_PORT_3306_TCP_ADDR", "127.0.0.1"),
'PORT': 3306, 'PORT': 3306,
'USER': 'root', 'USER': 'root',
'PASSWORD': 'mypwd' 'PASSWORD': os.environ.get("MYSQL_ENV_MYSQL_ROOT_PASSWORD", "root")
}, },
'submission': { 'submission': {
'NAME': 'oj_submission', 'NAME': 'oj_submission',
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
'CONN_MAX_AGE': 0.1, 'CONN_MAX_AGE': 0.1,
'HOST': "127.0.0.1", 'HOST': os.environ.get("MYSQL_PORT_3306_TCP_ADDR", "127.0.0.1"),
'PORT': 3306, 'PORT': 3306,
'USER': 'root', 'USER': 'root',
'PASSWORD': 'mypwd' 'PASSWORD': os.environ.get("MYSQL_ENV_MYSQL_ROOT_PASSWORD", "root")
} }
} }
REDIS_CACHE = { REDIS_CACHE = {
"host": "127.0.0.1", "host": os.environ.get("REDIS_PORT_6379_TCP_ADDR", "127.0.0.1"),
"port": 6379, "port": 6379,
"db": 1 "db": 1
} }
DEBUG = True DEBUG = False
# 同理 这是 web 服务器的上传路径
TEST_CASE_DIR = '/root/test_case/'
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['*']
IMAGE_UPLOAD_DIR = '/var/mnt/source/OnlineJudge/static/src/upload_image/' # 在 debug 关闭的情况下,静态文件不是有 django runserver 来处理的,应该由 nginx 返回
# 在 debug 开启的情况下django 会在下面两个文件夹中寻找对应的静态文件。
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static/release/")] STATICFILES_DIRS = [os.path.join(BASE_DIR, "static/release/"), os.path.join(BASE_DIR, "static/release/")]
# 模板文件夹
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'template/release/')] TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'template/release/')]

View File

@ -89,7 +89,6 @@ TEMPLATES = [
WSGI_APPLICATION = 'oj.wsgi.application' WSGI_APPLICATION = 'oj.wsgi.application'
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/ # https://docs.djangoproject.com/en/1.8/topics/i18n/
@ -111,6 +110,9 @@ STATIC_URL = '/static/'
AUTH_USER_MODEL = 'account.User' AUTH_USER_MODEL = 'account.User'
LOG_PATH = "log/"
LOGGING = { LOGGING = {
'version': 1, 'version': 1,
'disable_existing_loggers': True, 'disable_existing_loggers': True,
@ -162,4 +164,8 @@ REST_FRAMEWORK = {
'TEST_REQUEST_DEFAULT_FORMAT': 'json' 'TEST_REQUEST_DEFAULT_FORMAT': 'json'
} }
DATABASE_ROUTERS = ['oj.db_router.DBRouter'] DATABASE_ROUTERS = ['oj.db_router.DBRouter']
TEST_CASE_DIR = os.path.join(BASE_DIR, 'test_case/')
IMAGE_UPLOAD_DIR = os.path.join(BASE_DIR, 'upload/')

View File

@ -26,8 +26,8 @@ class SimditorImageUploadAPIView(APIView):
return Response(data={ return Response(data={
"success": True, "success": True,
"msg": "上传错误", "msg": "上传错误",
"file_path": "/static/upload_image/" + image_name}) "file_path": "/static/upload/" + image_name})
return Response(data={ return Response(data={
"success": True, "success": True,
"msg": "", "msg": "",
"file_path": "/static/upload_image/" + image_name}) "file_path": "/static/upload/" + image_name})