updated sample settings tu current version

This commit is contained in:
Adolfo Gómez García 2017-01-26 06:56:46 +01:00
parent eeaef4604a
commit 9b0e1eb7ce

View File

@ -5,36 +5,44 @@ Settings file for uds server (Django)
from __future__ import unicode_literals from __future__ import unicode_literals
import os import os
import sys
import django import django
import django.conf.global_settings as DEFAULT_SETTINGS import django.conf.global_settings as DEFAULT_SETTINGS
# Related to shell plus
NOTEBOOK_ARGUMENTS = [
'--ip=172.27.0.1',
'--port=8888',
]
# calculated paths for django and the site # calculated paths for django and the site
# used as starting points for various other paths # used as starting points for various other paths
DJANGO_ROOT = os.path.dirname(os.path.realpath(django.__file__)) DJANGO_ROOT = os.path.dirname(os.path.realpath(django.__file__))
BASE_DIR = '/'.join(os.path.dirname(os.path.realpath(__file__)).split('/')[:-1]) BASE_DIR = '/'.join(os.path.dirname(os.path.abspath(__file__)).split('/')[:-1]) # If used 'relpath' instead of abspath, returns path of "enterprise" instead of "openuds"
DEBUG = True DEBUG = True
TEMPLATE_DEBUG = DEBUG
# USE_X_FORWARDED_HOST = True # USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https') # For testing begind a reverse proxy SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https') # For testing behind a reverse proxy
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'OPTIONS': { 'OPTIONS': {
'init_command': 'SET default_storage_engine=INNODB; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;', 'init_command': 'SET default_storage_engine=INNODB; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;',
# 'init_command': 'SET storage_engine=INNODB, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED',
# 'init_command': 'SET storage_engine=MYISAM, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', # 'init_command': 'SET storage_engine=MYISAM, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED',
}, },
'NAME': 'dbuds', # Or path to database file if using sqlite3. # 'STORAGE_ENGINE': 'INNODB',
'USER': 'dbuds', # Not used with sqlite3. 'NAME': 'DBUDS', # Or path to database file if using sqlit00e3.
'PASSWORD': 'PASSWOR', # Not used with sqlite3. # 'NAME': 'dbuds2_test', # For creating tests
'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3. 'USER': 'DBUDS', # Not used with sqlite3.
'PORT': '3306', # Set to empty string for default. Not used with sqlite3. 'PASSWORD': 'PASSWR', # Not used with sqlite3.
# 'CONN_MAX_AGE': 600, # Enable DB Pooling, 10 minutes max connection duration 'HOST': 'SERVER', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
'CONN_MAX_AGE': 60, # Disable DB Pooling on development enviromnet
} }
} }
ALLOWED_HOSTS = '*' ALLOWED_HOSTS = '*'
# Local time zone for this installation. Choices can be found here: # Local time zone for this installation. Choices can be found here:
@ -45,7 +53,9 @@ ALLOWED_HOSTS = '*'
# If running in a Windows environment this must be set to the same as your # If running in a Windows environment this must be set to the same as your
# system time zone. # system time zone.
# TIME_SECTION_START
TIME_ZONE = 'Europe/Madrid' TIME_ZONE = 'Europe/Madrid'
# TIME_SECTION_END
# Language code for this installation. All choices can be found here: # Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html # http://www.i18nguy.com/unicode/language-identifiers.html
@ -137,10 +147,11 @@ FILE_UPLOAD_DIRECTORY_PERMISSIONS = 0o750
FILE_UPLOAD_MAX_MEMORY_SIZE = 512 * 1024 # 512 Kb FILE_UPLOAD_MAX_MEMORY_SIZE = 512 * 1024 # 512 Kb
# Make this unique, and don't share it with anybody. # Make this unique, and don't share it with anybody.
SECRET_KEY = 's5ky!7b5f#s35!e38xv%e-+iey6yi-#630x)tm1hf6_j8rie2*' SECRET_KEY = 's5ky!7b5f#s35!e38xv%e-+iey6yi-#630x)kk3kk5_j8rie2*'
# This is a very long string, an RSA KEY (this can be changed, but if u loose it, all encription will be lost) # This is a very long string, an RSA KEY (this can be changed, but if u loose it, all encription will be lost)
RSA_KEY = '-----BEGIN RSA PRIVATE KEY-----\nMIICXgIBAAKBgQC0qe1GlriQbHFYdKYRPBFDSS8Ne/TEKI2mtPKJf36XZTy6rIyH\nvUpT1gMScVjHjOISLNJQqktyv0G+ZGzLDmfkCUBev6JBlFwNeX3Dv/97Q0BsEzJX\noYHiDANUkuB30ukmGvG0sg1v4ccl+xs2Su6pFSc5bGINBcQ5tO0ZI6Q1nQIDAQAB\nAoGBAKA7Octqb+T/mQOX6ZXNjY38wXOXJb44LXHWeGnEnvUNf/Aci0L0epCidfUM\nfG33oKX4BMwwTVxHDrsa/HaXn0FZtbQeBVywZqMqWpkfL/Ho8XJ8Rsq8OfElrwek\nOCPXgxMzQYxoNHw8V97k5qhfupQ+h878BseN367xSyQ8plahAkEAuPgAi6aobwZ5\nFZhx/+6rmQ8sM8FOuzzm6bclrvfuRAUFa9+kMM2K48NAneAtLPphofqI8wDPCYgQ\nTl7O96GXVQJBAPoKtWIMuBHJXKCdUNOISmeEvEzJMPKduvyqnUYv17tM0JTV0uzO\nuDpJoNIwVPq5c3LJaORKeCZnt3dBrdH1FSkCQQC3DK+1hIvhvB0uUvxWlIL7aTmM\nSny47Y9zsc04N6JzbCiuVdeueGs/9eXHl6f9gBgI7eCD48QAocfJVygphqA1AkEA\nrvzZjcIK+9+pJHqUO0XxlFrPkQloaRK77uHUaW9IEjui6dZu4+2T/q7SjubmQgWR\nZy7Pap03UuFZA2wCoqJbaQJAUG0FVrnyUORUnMQvdDjAWps2sXoPvA8sbQY1W8dh\nR2k4TCFl2wD7LutvsdgdkiH0gWdh5tc1c4dRmSX1eQ27nA==\n-----END RSA PRIVATE KEY-----' RSA_KEY = '-----BEGIN RSA PRIVATE KEY-----\nMIICXgIBAAKBgQC0qe1GlriQbHFYdKYRPBFDSS8Ne/TEKI2mtPKJf36XZTy6rIyH\nvUpT1gMScVjHjOISLNJQqktyv0G+ZGzLDmfkCUBev6JBlFwNeX3Dv/97Q0BsEzJX\noYHiDANUkuB30ukmGvG0sg1v4ccl+xs2Su6pFSc5bGINBcQ5tO0ZI6Q1nQIDAQAB\nAoGBAKA7Octqb+T/mQOX6ZXNjY38wXOXJb44LXHWeGnEnvUNf/Aci0L0epCidfUM\nfG33oKX4BMwwTVxHDrsa/HaXn0FZtbQeBVywZqMqWpkfL/Ho8XJ8Rsq8OfElrwek\nOCPXgxMzQYxoNHw8V97k5qhfupQ+h878BseN367xSyQ8plahAkEAuPgAi6aobwZ5\nFZhx/+6rmQ8sM8FOuzzm6bclrvfuRAUFa9+kMM2K48NAneAtLPphofqI8wDPCYgQ\nTl7O96GXVQJBAPoKtWIMuBHJXKCdUNOISmeEvEzJMPKduvyqnUYv17tM0JTV0uzO\nuDpJoNIwVPq5c3LJaORKeCZnt3dBrdH1FSkCQQC3DK+1hIvhvB0uUvxWlIL7aTmM\nSny47Y9zsc04N6JzbCiuVdeueGs/9eXHl6f9gBgI7eCD48QAocfJVygphqA1AkEA\nrvzZjcIK+9+pJHqUO0XxlFrPkQloaRK77uHUaW9IEjui6dZu4+2T/q7SjubmQgWR\nZy7Pap03UuFZA2wCoqJbaQJAUG0FVrnyUORUnMQvdDjAWps2sXoPvA8sbQY1W8dh\nR2k4TCFl2wD7LutvsdgdkiH0gWdh5tc1c4dRmSX1eQ27nA==\n-----END RSA PRIVATE KEY-----'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
@ -159,7 +170,7 @@ TEMPLATES = [
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'uds.core.util.Config.context_processor', 'uds.core.util.Config.context_processor',
'uds.core.util.html.context', 'uds.core.util.html.context',
'django.core.context_processors.request', 'django.template.context_processors.request',
], ],
'debug': DEBUG, 'debug': DEBUG,
}, },
@ -172,9 +183,11 @@ MIDDLEWARE = [
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'uds.core.util.request.GlobalRequestMiddleware', 'uds.core.util.request.GlobalRequestMiddleware',
'uds.core.util.middleware.XUACompatibleMiddleware', 'uds.core.util.middleware.XUACompatibleMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'uds.plugins.enterprise.middleware.Middleware',
] ]
SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_EXPIRE_AT_BROWSER_CLOSE = True
@ -188,18 +201,12 @@ ROOT_URLCONF = 'server.urls'
# Python dotted path to the WSGI application used by Django's runserver. # Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'server.wsgi.application' WSGI_APPLICATION = 'server.wsgi.application'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(BASE_DIR, 'templates'),
)
INSTALLED_APPS = ( INSTALLED_APPS = (
# 'django.contrib.contenttypes', # Not used # 'django.contrib.contenttypes', # Not used
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'django_extensions',
'compressor', 'compressor',
'uds', 'uds',
) )
@ -207,8 +214,11 @@ INSTALLED_APPS = (
# Compressor settings (for css/js) # Compressor settings (for css/js)
COMPRESS_ENABLED = not DEBUG COMPRESS_ENABLED = not DEBUG
COMPRESS_OUTPUT_DIR = 'cache' COMPRESS_OUTPUT_DIR = 'cache'
COMPRESS_CACHE_BACKEND = 'default' # 'memory'
COMPRESS_STORAGE = 'uds.core.util.FileStorage.CompressorFileStorage'
COMPRESS_PRECOMPILERS = ( COMPRESS_PRECOMPILERS = (
('text/coffeescript', 'coffee --compile --stdio'), ('text/coffeescript', 'coffee --compile --stdio'), # Original, unchanged
# ('text/coffeescript', 'coffee --compile -p {infile} | babel --blacklist strict -o {outfile}'), # Allows use of generators, etc.. on unsupported browers
('text/less', 'lessc {infile} {outfile}'), ('text/less', 'lessc {infile} {outfile}'),
('text/x-sass', 'sass {infile} {outfile}'), ('text/x-sass', 'sass {infile} {outfile}'),
('text/x-scss', 'sass --scss {infile} {outfile}'), ('text/x-scss', 'sass --scss {infile} {outfile}'),
@ -217,11 +227,11 @@ COMPRESS_PRECOMPILERS = (
) )
if DEBUG: if DEBUG:
COMPRESS_DEBUG_TOGGLE = 'debug' COMPRESS_DEBUG_TOGGLE = 'debug'
# #
# Enable this if you need to allow round robin load balancing of web server # Enable this if you need to allow round robin load balancing of web server
# This is so because we need to share the files between servers # This is so because we need to share the files between servers
# Another options is put /var/server/static on a shared nfs forder for all servers # Another options is put /var/server/static on a shared nfs forder for all servers
# #
# COMPRESS_STORAGE = 'uds.core.util.FileStorage.CompressorFileStorage' # COMPRESS_STORAGE = 'uds.core.util.FileStorage.CompressorFileStorage'
# See http://docs.djangoproject.com/en/dev/topics/logging for # See http://docs.djangoproject.com/en/dev/topics/logging for
@ -229,28 +239,27 @@ if DEBUG:
LOGDIR = BASE_DIR + '/' + 'log' LOGDIR = BASE_DIR + '/' + 'log'
LOGFILE = 'uds.log' LOGFILE = 'uds.log'
SERVICESFILE = 'services.log' SERVICESFILE = 'services.log'
WORKERSFILE = 'workers.log'
AUTHFILE = 'auth.log' AUTHFILE = 'auth.log'
USEFILE = 'use.log' USEFILE = 'use.log'
TRACEFILE = 'trace.log'
LOGLEVEL = DEBUG and 'DEBUG' or 'INFO' LOGLEVEL = DEBUG and 'DEBUG' or 'INFO'
ROTATINGSIZE = 32 * 1024 * 1024 # 32 Megabytes before rotating files ROTATINGSIZE = 32 * 1024 * 1024 # 32 Megabytes before rotating files
# Tests runner is default tests runner
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
LOGGING = { LOGGING = {
'version': 1, 'version': 1,
'disable_existing_loggers': True, 'disable_existing_loggers': True,
'filters': { 'filters': {
'require_debug_false': { 'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse', '()': 'django.utils.log.RequireDebugFalse',
} }
}, },
'formatters': { 'formatters': {
'verbose': { 'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
}, },
'simple': { 'simple': {
'format': '%(levelname)s %(asctime)s %(module)s %(message)s' 'format': '%(levelname)s %(asctime)s %(module)s %(funcName)s %(lineno)d %(message)s'
}, },
'database': { 'database': {
'format': '%(levelname)s %(asctime)s Database %(message)s' 'format': '%(levelname)s %(asctime)s Database %(message)s'
@ -260,17 +269,20 @@ LOGGING = {
}, },
'use': { 'use': {
'format': '%(asctime)s %(message)s' 'format': '%(asctime)s %(message)s'
},
'trace': {
'format': '%(levelname)s %(asctime)s %(message)s'
} }
}, },
'handlers': { 'handlers': {
'null': { 'null': {
'level':'DEBUG', 'level': 'DEBUG',
'class':'logging.NullHandler', 'class': 'logging.NullHandler',
}, },
'file':{ 'file': {
'level':'DEBUG', 'level': 'DEBUG',
'class':'logging.handlers.RotatingFileHandler', 'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'simple', 'formatter': 'simple',
'filename': LOGDIR + '/' + LOGFILE, 'filename': LOGDIR + '/' + LOGFILE,
'mode': 'a', 'mode': 'a',
@ -279,20 +291,20 @@ LOGGING = {
'encoding': 'utf-8' 'encoding': 'utf-8'
}, },
'database':{ 'database': {
'level':'ERROR', 'level': 'DEBUG',
'class':'logging.handlers.RotatingFileHandler', 'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'simple', 'formatter': 'simple',
'filename': LOGDIR + '/' + 'db.log', 'filename': LOGDIR + '/' + 'sql.log',
'mode': 'a', 'mode': 'a',
'maxBytes': ROTATINGSIZE, 'maxBytes': ROTATINGSIZE,
'backupCount': 3, 'backupCount': 3,
'encoding': 'utf-8' 'encoding': 'utf-8'
}, },
'servicesFile':{ 'servicesFile': {
'level':'DEBUG', 'level': 'DEBUG',
'class':'logging.handlers.RotatingFileHandler', 'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'simple', 'formatter': 'simple',
'filename': LOGDIR + '/' + SERVICESFILE, 'filename': LOGDIR + '/' + SERVICESFILE,
'mode': 'a', 'mode': 'a',
@ -301,9 +313,20 @@ LOGGING = {
'encoding': 'utf-8' 'encoding': 'utf-8'
}, },
'authFile':{ 'workersFile': {
'level':'DEBUG', 'level': 'DEBUG',
'class':'logging.handlers.RotatingFileHandler', 'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'simple',
'filename': LOGDIR + '/' + WORKERSFILE,
'mode': 'a',
'maxBytes': ROTATINGSIZE,
'backupCount': 3,
'encoding': 'utf-8'
},
'authFile': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'auth', 'formatter': 'auth',
'filename': LOGDIR + '/' + AUTHFILE, 'filename': LOGDIR + '/' + AUTHFILE,
'mode': 'a', 'mode': 'a',
@ -312,9 +335,9 @@ LOGGING = {
'encoding': 'utf-8' 'encoding': 'utf-8'
}, },
'useFile':{ 'useFile': {
'level':'DEBUG', 'level': 'DEBUG',
'class':'logging.handlers.RotatingFileHandler', 'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'use', 'formatter': 'use',
'filename': LOGDIR + '/' + USEFILE, 'filename': LOGDIR + '/' + USEFILE,
'mode': 'a', 'mode': 'a',
@ -322,10 +345,21 @@ LOGGING = {
'backupCount': 3, 'backupCount': 3,
'encoding': 'utf-8' 'encoding': 'utf-8'
}, },
'console':{ 'traceFile': {
'level':'DEBUG', 'level': 'DEBUG',
'class':'logging.StreamHandler', 'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'trace',
'filename': LOGDIR + '/' + TRACEFILE,
'mode': 'a',
'maxBytes': ROTATINGSIZE,
'backupCount': 3,
'encoding': 'utf-8'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple' 'formatter': 'simple'
}, },
'mail_admins': { 'mail_admins': {
@ -336,9 +370,9 @@ LOGGING = {
}, },
'loggers': { 'loggers': {
'django': { 'django': {
'handlers':['null'], 'handlers': ['null'],
'propagate': True, 'propagate': True,
'level':'INFO', 'level': 'INFO',
}, },
'django.request': { 'django.request': {
'handlers': ['file'], 'handlers': ['file'],
@ -347,15 +381,26 @@ LOGGING = {
}, },
'django.db.backends': { 'django.db.backends': {
'handlers': ['database'], 'handlers': ['database'],
'level': 'ERROR', 'level': 'DEBUG',
'propagate': False, 'propagate': False,
}, },
'uds': { 'uds': {
'handlers': ['file'], 'handlers': ['file'],
'level': LOGLEVEL, 'level': LOGLEVEL,
}, },
'uds.core.workers': {
'handlers': ['workersFile'],
'level': LOGLEVEL,
'propagate': False,
},
'uds.core.jobs': {
'handlers': ['workersFile'],
'level': LOGLEVEL,
'propagate': False,
},
'uds.services': { 'uds.services': {
'handlers': ['servicesFile'], 'handlers': ['servicesFile'],
'level': LOGLEVEL, 'level': LOGLEVEL,
@ -363,16 +408,22 @@ LOGGING = {
}, },
# Custom Auth log # Custom Auth log
'authLog': { 'authLog': {
'handlers' : ['authFile'], 'handlers': ['authFile'],
'level': 'INFO', 'level': 'INFO',
'propagate': False, 'propagate': False,
}, },
# Custom Services use log # Custom Services use log
'useLog': { 'useLog': {
'handlers' : ['useFile'], 'handlers': ['useFile'],
'level': 'INFO',
'propagate': False,
},
# Custom tracing
'traceLog': {
'handlers': ['traceFile'],
'level': 'INFO', 'level': 'INFO',
'propagate': False, 'propagate': False,
} }
} }
} }