# since it hides configuration outside of the repository, plus could lead to # drift between environments. for alias in DATABASES: # Persist database connections for 5 minutes, to avoid expensive reconnects. DATABASES[alias]['CONN_MAX_AGE'] = 300 DATABASES[alias]['OPTIONS'] = { # Override Django's default connection charset of 'utf8', otherwise it's # still not possible to insert non-BMP unicode into utf8mb4 tables. 'charset': 'utf8mb4', # From MySQL 5.7 onwards and on fresh installs of MySQL 5.6, the default value of the sql_mode # option contains STRICT_TRANS_TABLES. That option escalates warnings into errors when data are # truncated upon insertion, so Django highly recommends activating a strict mode for MySQL to # prevent data loss (either STRICT_TRANS_TABLES or STRICT_ALL_TABLES). 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", } if connection_should_use_tls(DATABASES[alias]['HOST']): # Use TLS when connecting to RDS. # https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html#MySQL.Concepts.SSLSupport # https://mysqlclient.readthedocs.io/user_guide.html#functions-and-attributes DATABASES[alias]['OPTIONS']['ssl'] = { 'ca': 'deployment/aws/rds-combined-ca-bundle.pem', } # Caches REDIS_URL = env('REDIS_URL', default='redis://localhost:6379') if connection_should_use_tls(REDIS_URL): # Connect using TLS on Heroku. REDIS_URL = get_tls_redis_url(REDIS_URL) CACHES = { 'default': {
Queue('fetch_runnablejobs', Exchange('default'), routing_key='fetch_runnablejobs'), Queue('cycle_data', Exchange('default'), routing_key='cycle_data'), Queue('fetch_bugs', Exchange('default'), routing_key='fetch_bugs'), Queue('generate_perf_alerts', Exchange('default'), routing_key='generate_perf_alerts'), Queue('store_pulse_jobs', Exchange('default'), routing_key='store_pulse_jobs'), Queue('store_pulse_resultsets', Exchange('default'), routing_key='store_pulse_resultsets'), Queue('seta_analyze_failures', Exchange('default'), routing_key='seta_analyze_failures'), ] # Celery broker setup BROKER_URL = env('BROKER_URL') # Force Celery to use TLS when appropriate (ie if not localhost), # rather than relying on `BROKER_URL` having `amqps://` or `?ssl=` set. # This is required since CloudAMQP's automatically defined URL uses neither. if connection_should_use_tls(BROKER_URL): BROKER_USE_SSL = True # Recommended by CloudAMQP: # https://www.cloudamqp.com/docs/celery.html BROKER_HEARTBEAT = None BROKER_CONNECTION_TIMEOUT = 30 CELERY_RESULT_BACKEND = None CELERY_SEND_EVENTS = False CELERY_EVENT_QUEUE_EXPIRES = 60 CELERY_IGNORE_RESULT = True CELERY_ACCEPT_CONTENT = ['json'] CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json'
# Persist database connections for 5 minutes, to avoid expensive reconnects. DATABASES[alias]['CONN_MAX_AGE'] = 300 DATABASES[alias]['OPTIONS'] = { # Override Django's default connection charset of 'utf8', otherwise it's # still not possible to insert non-BMP unicode into utf8mb4 tables. 'charset': 'utf8mb4', } if DATABASES[alias]['HOST'] != 'localhost': # Use TLS when connecting to RDS. DATABASES[alias]['OPTIONS']['ssl'] = { 'ca': 'deployment/aws/combined-ca-bundle.pem', } # Caches REDIS_URL = env('REDIS_URL') if connection_should_use_tls(REDIS_URL): # Connect using TLS on Heroku. REDIS_URL = get_tls_redis_url(REDIS_URL) CACHES = { 'default': { 'BACKEND': 'django_redis.cache.RedisCache', 'LOCATION': REDIS_URL, 'OPTIONS': { # Override the default of no timeout, to avoid connection hangs. 'SOCKET_CONNECT_TIMEOUT': 5, }, }, } # Internationalization
UPSTREAM_DATABASE_URL = env('UPSTREAM_DATABASE_URL', default=None) if UPSTREAM_DATABASE_URL: DATABASES['upstream'] = env.db_url_config(UPSTREAM_DATABASE_URL) # We're intentionally not using django-environ's query string options feature, # since it hides configuration outside of the repository, plus could lead to # drift between environments. for alias in DATABASES: # Persist database connections for 5 minutes, to avoid expensive reconnects. DATABASES[alias]['CONN_MAX_AGE'] = 300 DATABASES[alias]['OPTIONS'] = { # Override Django's default connection charset of 'utf8', otherwise it's # still not possible to insert non-BMP unicode into utf8mb4 tables. 'charset': 'utf8mb4', } if connection_should_use_tls(DATABASES[alias]['HOST']): # Use TLS when connecting to RDS. # https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html#MySQL.Concepts.SSLSupport # https://mysqlclient.readthedocs.io/user_guide.html#functions-and-attributes DATABASES[alias]['OPTIONS']['ssl'] = { 'ca': 'deployment/aws/rds-combined-ca-bundle.pem', } # Caches REDIS_URL = env('REDIS_URL') if connection_should_use_tls(REDIS_URL): # Connect using TLS on Heroku. REDIS_URL = get_tls_redis_url(REDIS_URL) CACHES = { 'default': {