diff --git a/gvapgsql/gvapgsql/__init__.py b/gvapgsql/gvapgsql/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gvapgsql/gvapgsql/celery.py b/gvapgsql/gvapgsql/celery.py new file mode 100644 index 0000000..a99dd76 --- /dev/null +++ b/gvapgsql/gvapgsql/celery.py @@ -0,0 +1,15 @@ +""" +This module defines the Celery_ app for gvapgsql. + +.. _Celery: http://www.celeryproject.org/ + +""" +from __future__ import absolute_import + +from celery import Celery + +#: The Celery application +app = Celery('gvapgsql') + +app.config_from_object('gvapgsql.settings') +app.autodiscover_tasks(['pgsqltasks'], force=True) diff --git a/gvapgsql/gvapgsql/settings.py b/gvapgsql/gvapgsql/settings.py new file mode 100644 index 0000000..5de01b4 --- /dev/null +++ b/gvapgsql/gvapgsql/settings.py @@ -0,0 +1,47 @@ +# -*- 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 +CELERY_TIMEZONE = 'Europe/Berlin' +CELERY_ENABLE_UTC = True +CELERY_RESULT_BACKEND = 'amqp' +CELERY_RESULT_PERSISTENT = True +CELERY_TASK_RESULT_EXPIRES = None +CELERY_ROUTES = ( + 'gvacommon.celeryrouters.GvaRouter', +) +CELERY_ACCEPT_CONTENT = ['json'] +CELERY_TASK_SERIALIZER = 'json' +CELERY_RESULT_SERIALIZER = 'json' +BROKER_URL = get_env_setting('GVAPGSQL_BROKER_URL') +########## 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