|
@@ -0,0 +1,190 @@
|
|
|
+"""
|
|
|
+Django settings for TkMoldingServer project.
|
|
|
+
|
|
|
+Generated by 'django-admin startproject' using Django 2.2.
|
|
|
+
|
|
|
+For more information on this file, see
|
|
|
+https://docs.djangoproject.com/en/2.2/topics/settings/
|
|
|
+
|
|
|
+For the full list of settings and their values, see
|
|
|
+https://docs.djangoproject.com/en/2.2/ref/settings/
|
|
|
+"""
|
|
|
+
|
|
|
+import os
|
|
|
+
|
|
|
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
|
+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/2.2/howto/deployment/checklist/
|
|
|
+
|
|
|
+# SECURITY WARNING: keep the secret key used in production secret!
|
|
|
+SECRET_KEY = '(_g3+3n*140t!k&g1drctb19=%8_hq-r$18pub-d-vtyl=89t)'
|
|
|
+
|
|
|
+# SECURITY WARNING: don't run with debug turned on in production!
|
|
|
+DEBUG = False
|
|
|
+
|
|
|
+ALLOWED_HOSTS = ['*']
|
|
|
+
|
|
|
+
|
|
|
+# Application definition
|
|
|
+
|
|
|
+INSTALLED_APPS = [
|
|
|
+ 'django_crontab',
|
|
|
+ 'tkschedule.apps.ScheduleConfig',
|
|
|
+ 'django.contrib.admin',
|
|
|
+ 'django.contrib.auth',
|
|
|
+ 'django.contrib.contenttypes',
|
|
|
+ 'django.contrib.sessions',
|
|
|
+ 'django.contrib.messages',
|
|
|
+ 'django.contrib.staticfiles',
|
|
|
+]
|
|
|
+
|
|
|
+MIDDLEWARE = [
|
|
|
+ 'django.middleware.security.SecurityMiddleware',
|
|
|
+ 'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
+ 'django.middleware.common.CommonMiddleware',
|
|
|
+ 'django.middleware.csrf.CsrfViewMiddleware',
|
|
|
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
+ 'django.contrib.messages.middleware.MessageMiddleware',
|
|
|
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
|
+]
|
|
|
+
|
|
|
+ROOT_URLCONF = 'TkMoldingServer.urls'
|
|
|
+
|
|
|
+TEMPLATES = [
|
|
|
+ {
|
|
|
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
+ 'DIRS': [],
|
|
|
+ 'APP_DIRS': True,
|
|
|
+ 'OPTIONS': {
|
|
|
+ 'context_processors': [
|
|
|
+ 'django.template.context_processors.debug',
|
|
|
+ 'django.template.context_processors.request',
|
|
|
+ 'django.contrib.auth.context_processors.auth',
|
|
|
+ 'django.contrib.messages.context_processors.messages',
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+]
|
|
|
+
|
|
|
+WSGI_APPLICATION = 'TkMoldingServer.wsgi.application'
|
|
|
+
|
|
|
+
|
|
|
+# Database
|
|
|
+# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
|
|
+
|
|
|
+DATABASES = {
|
|
|
+ 'default': {
|
|
|
+ 'ENGINE': 'django.db.backends.mysql',
|
|
|
+ 'NAME': 'moldingdatabase',
|
|
|
+ 'USER': 'hsmolding',
|
|
|
+ 'PASSWORD': '87543492',
|
|
|
+ 'HOST': '120.24.182.114',
|
|
|
+ 'PORT': '3306',
|
|
|
+ },
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+# Password validation
|
|
|
+# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
|
|
+
|
|
|
+AUTH_PASSWORD_VALIDATORS = [
|
|
|
+ {
|
|
|
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
|
+ },
|
|
|
+]
|
|
|
+
|
|
|
+
|
|
|
+# Internationalization
|
|
|
+# https://docs.djangoproject.com/en/2.2/topics/i18n/
|
|
|
+
|
|
|
+LANGUAGE_CODE = 'zh-hans'
|
|
|
+
|
|
|
+TIME_ZONE = 'Asia/Shanghai'
|
|
|
+
|
|
|
+USE_I18N = True
|
|
|
+
|
|
|
+USE_L10N = True
|
|
|
+
|
|
|
+USE_TZ = True
|
|
|
+
|
|
|
+
|
|
|
+# Static files (CSS, JavaScript, Images)
|
|
|
+# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
|
|
+
|
|
|
+STATIC_URL = '/static/'
|
|
|
+
|
|
|
+# 日志文件存放路径
|
|
|
+BASE_LOG_DIR = os.path.join(BASE_DIR, "logs")
|
|
|
+# Logging配置
|
|
|
+LOGGING = {
|
|
|
+ 'version': 1.0, # 保留字
|
|
|
+ 'disable_existing_loggers': False, # 是否禁用Django框架开发的时候已经存在的Logger实例
|
|
|
+ 'formatters': { # 格式化器
|
|
|
+ 'standard': { # 标准的格式
|
|
|
+ 'format': '[%(asctime)s][%(threadName)s:%(thread)d][task_id:%(name)s][%(filename)s:%(lineno)d]'
|
|
|
+ '[%(levelname)s][%(message)s]'
|
|
|
+ },
|
|
|
+ 'simple': { # 简单的格式
|
|
|
+ 'format': '[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d]%(message)s'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'filters': { # 过滤器
|
|
|
+ 'require_debug_true': {
|
|
|
+ '()': 'django.utils.log.RequireDebugTrue',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ 'handlers': { # 处理器
|
|
|
+ 'console': { # 定义一个在终端输出的处理器
|
|
|
+ 'level': 'DEBUG', # 日志级别
|
|
|
+ 'filters': ['require_debug_true'], # 只有在Django debug为True时才在屏幕打印日志
|
|
|
+ 'class': 'logging.StreamHandler', # 日志流
|
|
|
+ 'formatter': 'simple' # 用简单格式打印日志
|
|
|
+ },
|
|
|
+ 'info': { # 定义一个名为SF的日志处理器(名字自己定义即可)
|
|
|
+ 'level': 'INFO', # 日志级别
|
|
|
+ 'class': 'logging.handlers.RotatingFileHandler', # 保存到文件,根据文件大小自动切
|
|
|
+ 'filename': os.path.join(BASE_LOG_DIR, "serverinfo.log"), # 日志文件
|
|
|
+ 'maxBytes': 1024 * 1024 * 20, # 日志大小 50M
|
|
|
+ 'backupCount': 3, # 备份数为3 xx.log --> xx.log.1 --> xx.log.2 --> xx.log.3
|
|
|
+ 'formatter': 'standard', # 用标准格式打印日志
|
|
|
+ 'encoding': 'utf-8',
|
|
|
+ },
|
|
|
+ 'warning': {
|
|
|
+ 'level': 'WARNING',
|
|
|
+ 'class': 'logging.handlers.RotatingFileHandler', # 保存到文件,自动切
|
|
|
+ 'filename': os.path.join(BASE_LOG_DIR, "serverwarning.log"), # 日志文件
|
|
|
+ 'maxBytes': 1024 * 1024 * 20, # 日志大小 50M
|
|
|
+ 'backupCount': 3,
|
|
|
+ 'formatter': 'standard',
|
|
|
+ 'encoding': 'utf-8',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ 'loggers': {
|
|
|
+ 'django': { # 日志实例对象默认配置
|
|
|
+ 'handlers': ['warning'], # 使用哪几种处理器,上线之后可以把'console'移除
|
|
|
+ 'level': 'DEBUG', # 实例的级别
|
|
|
+ 'propagate': True, # 是否向上传递日志流
|
|
|
+ },
|
|
|
+ 'tkschedule.views': { # logger对象实例还单独处理
|
|
|
+ 'handlers': ['info'],
|
|
|
+ 'level': 'INFO',
|
|
|
+ }
|
|
|
+ },
|
|
|
+}
|
|
|
+
|
|
|
+CRONJOBS = [
|
|
|
+('50 8 * * *', 'tkschedule.tasks.testEmail'),
|
|
|
+]
|
|
|
+
|