forked from DataDog/gello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
109 lines (86 loc) · 2.87 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# -*- coding: utf-8 -*-
#
# Unless explicitly stated otherwise all files in this repository are licensed
# under the Apache 2 License.
#
# This product includes software developed at Datadog
# (https://www.datadoghq.com/).
#
# Copyright 2018 Datadog, Inc.
#
"""config.py
Configuration for the Flask application.
"""
import os
from flask_dotenv import DotEnv
class Config:
APM_ENABLED = 'APM_ENABLED' in os.environ
BROKER_POOL_LIMIT = 0
CELERY_BROKER_URL = os.environ.get('REDIS_URL') or \
'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = os.environ.get('REDIS_URL') or \
'redis://localhost:6379/0'
SECRET_KEY = os.environ.get('SECRET_KEY') or 'bad_secret_key'
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
SQLALCHEMY_RECORD_QUERIES = True
SQLALCHEMY_TRACK_MODIFICATIONS = False
SSL_DISABLE = False
# Note:
# Before adding repo-label pair, please make sure label
# (eg. 'Go') exists on respective Trello board
REPO_LABELS = {
'dd-trace-go': 'Go',
'dd-trace-php': 'PHP',
'dd-trace-py': 'Python',
'dd-trace-rb': 'Ruby',
'dd-trace-java': 'Java',
'dd-trace-js': 'JavaScript',
'dd-trace-dotnet': '.NET',
'dd-opentracing-cpp': 'CPP',
}
@staticmethod
def init_app(app):
env_file_path = os.path.join(app.root_path, '../', '.env')
if os.path.exists(env_file_path):
env = DotEnv()
env.init_app(app)
class DevelopmentConfig(Config):
"""Configuration for development environment."""
DEBUG = True
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
class TestingConfig(Config):
"""Configuration for testing environment."""
CELERY_ALWAYS_EAGER = True
TESTING = True
SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL')
WTF_CSRF_ENABLED = False
class ProductionConfig(Config):
"""Configuration for testing production."""
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
@classmethod
def init_app(cls, app):
"""Initializes production application."""
Config.init_app(app)
class HerokuConfig(ProductionConfig):
"""Configuration for Heroku."""
SSL_DISABLE = bool(os.environ.get('SSL_DISABLE'))
@classmethod
def init_app(cls, app):
"""Initializes Heroku application."""
ProductionConfig.init_app(app)
# handle proxy server headers
from werkzeug.contrib.fixers import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app)
# log to stderr
import logging
from logging import StreamHandler
file_handler = StreamHandler()
file_handler.setLevel(logging.WARNING)
app.logger.addHandler(file_handler)
config = {
'development': DevelopmentConfig,
'testing': TestingConfig,
'production': ProductionConfig,
'heroku': HerokuConfig,
'default': DevelopmentConfig
}