gvapgsql/gvapgsql/pgsqltasks/settings.py
Jan Dittberner 69a8177c4b Improve docker setup
- add .dockerignore
- add entrypoint.sh to switch to user after initial setup
- downgrade importlib-metadata for Celery compatibility
- add TZ environment variable for consistent Celery timestamps
- fix Celery setting deprecation warnings
2023-02-20 15:49:17 +01:00

46 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
# pymode:lint_ignore=E501
"""
Common settings and globals.
"""
from os import environ
def get_env_setting(setting):
"""
Get the environment setting or return exception.
:param str setting: name of an environment setting
:raises ImproperlyConfigured: if the environment setting is not defined
:return: environment setting value
:rtype: str
"""
try:
return environ[setting]
except KeyError:
error_msg = "Set the %s env variable" % setting
raise AssertionError(error_msg)
########## CELERY CONFIGURATION
accept_content = ["json"]
broker_url = get_env_setting("GVAPGSQL_BROKER_URL")
enable_utc = True
result_backend = get_env_setting("GVAPGSQL_RESULTS_REDIS_URL")
result_expires = None
result_persistent = True
result_serializer = "json"
task_routes = ("gvacommon.celeryrouters.GvaRouter",)
task_serializer = "json"
timezone = "Europe/Berlin"
########## END CELERY CONFIGURATION
########## GVAPGSQL CONFIGURATION
GVAPGSQL_DBADMIN_HOST = get_env_setting("GVAPGSQL_DBADMIN_HOST")
GVAPGSQL_DBADMIN_PORT = int(get_env_setting("GVAPGSQL_DBADMIN_PORT"))
GVAPGSQL_DBADMIN_USER = get_env_setting("GVAPGSQL_DBADMIN_USER")
GVAPGSQL_DBADMIN_PASSWORD = get_env_setting("GVAPGSQL_DBADMIN_PASSWORD")
########## END GVAPGSQL CONFIGURATION