2
0

pro.py.sample 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.AppPermissionCheck',
  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.postgresql',
  25. 'NAME': os.getenv('DB_NAME', 'loonflow'),
  26. 'USER': os.getenv('DB_USER', 'loonflow'),
  27. 'PASSWORD': os.getenv('DB_PASS', '123456'),
  28. 'HOST': os.getenv('DB_HOST', '127.0.0.1'),
  29. 'PORT': '5432',
  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_FORBIDDEN = [] # host list that not allowed be used as hook url(include state hook and notice hook), such as ['192,168.1.12', '*.baidu.com'], if no this setting key means allow all
  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. }