mirror of
https://github.com/apache/superset.git
synced 2024-09-17 19:19:38 -04:00
43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
|
import os
|
||
|
|
||
|
|
||
|
def get_env_variable(var_name, default=None):
|
||
|
"""Get the environment variable or raise exception."""
|
||
|
try:
|
||
|
return os.environ[var_name]
|
||
|
except KeyError:
|
||
|
if default is not None:
|
||
|
return default
|
||
|
else:
|
||
|
error_msg = 'The environment variable {} was missing, abort...'\
|
||
|
.format(var_name)
|
||
|
raise EnvironmentError(error_msg)
|
||
|
|
||
|
|
||
|
POSTGRES_USER = get_env_variable('POSTGRES_USER')
|
||
|
POSTGRES_PASSWORD = get_env_variable('POSTGRES_PASSWORD')
|
||
|
POSTGRES_HOST = get_env_variable('POSTGRES_HOST')
|
||
|
POSTGRES_PORT = get_env_variable('POSTGRES_PORT')
|
||
|
POSTGRES_DB = get_env_variable('POSTGRES_DB')
|
||
|
|
||
|
# The SQLAlchemy connection string.
|
||
|
SQLALCHEMY_DATABASE_URI = 'postgresql://%s:%s@%s:%s/%s' % (POSTGRES_USER,
|
||
|
POSTGRES_PASSWORD,
|
||
|
POSTGRES_HOST,
|
||
|
POSTGRES_PORT,
|
||
|
POSTGRES_DB)
|
||
|
|
||
|
REDIS_HOST = get_env_variable('REDIS_HOST')
|
||
|
REDIS_PORT = get_env_variable('REDIS_PORT')
|
||
|
|
||
|
|
||
|
class CeleryConfig(object):
|
||
|
BROKER_URL = 'redis://%s:%s/0' % (REDIS_HOST, REDIS_PORT)
|
||
|
CELERY_IMPORTS = ('superset.sql_lab', )
|
||
|
CELERY_RESULT_BACKEND = 'redis://%s:%s/1' % (REDIS_HOST, REDIS_PORT)
|
||
|
CELERY_ANNOTATIONS = {'tasks.add': {'rate_limit': '10/s'}}
|
||
|
CELERY_TASK_PROTOCOL = 1
|
||
|
|
||
|
|
||
|
CELERY_CONFIG = CeleryConfig
|