2
0

pro.py.sample 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import os
  2. from settings.common import *
  3. # for multi computer room deploy and use separate redis server
  4. DEPLOY_ZONE = ''
  5. MIDDLEWARE = [
  6. 'service.csrf_service.DisableCSRF',
  7. 'django.middleware.security.SecurityMiddleware',
  8. 'django.contrib.sessions.middleware.SessionMiddleware',
  9. 'django.middleware.common.CommonMiddleware',
  10. 'django.middleware.csrf.CsrfViewMiddleware',
  11. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  12. 'service.permission.api_permission.ApiPermissionCheck',
  13. 'django.contrib.messages.middleware.MessageMiddleware',
  14. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  15. ]
  16. DEBUG = False
  17. ALLOWED_HOSTS = ['*']
  18. MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  19. MEDIA_URL = '/media/'
  20. # Database
  21. # https://docs.djangoproject.com/en/1.11/ref/settings/#databases
  22. DATABASES = {
  23. 'default': {
  24. 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
  25. 'NAME': os.getenv('DB_NAME', 'loonflow'), # Or path to database file if using sqlite3.
  26. 'USER': os.getenv('DB_USER', 'loonflow'), # Not used with sqlite3.
  27. 'PASSWORD': os.getenv('DB_PASS', '123456'), # Not used with sqlite3.
  28. 'HOST': os.getenv('DB_HOST', '127.0.0.1'), # Set to empty string for localhost. Not used with sqlite3.
  29. 'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
  30. }
  31. }
  32. REDIS_HOST = os.getenv('REDIS_HOST', '127.0.0.1')
  33. REDIS_PORT = 6379
  34. REDIS_DB = 0
  35. REDIS_PASSWORD = os.getenv('REDIS_PASS', 'loonflow123')
  36. if REDIS_PASSWORD:
  37. CELERY_BROKER_URL = 'redis://:{}@{}:{}/{}'.format(REDIS_PASSWORD, REDIS_HOST, REDIS_PORT, REDIS_DB)
  38. else:
  39. CELERY_BROKER_URL = 'redis://{}:{}/{}'.format(REDIS_HOST, REDIS_PORT, REDIS_DB)
  40. HOOK_HOST_ALLOWED = [] # host list that allow used as hook url, such as ['192,168.1.12', 'www.baidu.com'], if no this setting key means allow
  41. LOGGING = {
  42. 'version': 1,
  43. 'disable_existing_loggers': False,
  44. 'filters': {
  45. 'require_debug_true': {
  46. '()': 'django.utils.log.RequireDebugTrue',
  47. },
  48. },
  49. 'formatters': {
  50. 'standard': {
  51. 'format': '%(asctime)s %(pathname)s process-%(process)d thread-%(thread)d %(lineno)d [%(levelname)s]: %(message)s',
  52. },
  53. },
  54. 'handlers': {
  55. 'file_handler': {
  56. 'level': 'INFO',
  57. 'class': 'logging.FileHandler',
  58. 'filename': HOMEPATH + '/loonflow.log',
  59. 'formatter': 'standard'
  60. },
  61. 'console': {
  62. 'level': 'INFO',
  63. 'filters': ['require_debug_true'],
  64. 'class': 'logging.StreamHandler',
  65. 'formatter': 'standard'
  66. },
  67. },
  68. 'loggers': {
  69. 'django': {
  70. 'handlers': ['console','file_handler'],
  71. 'propagate': True,
  72. 'level': 'INFO',
  73. },
  74. }
  75. }