Skip to content
Snippets Groups Projects
Commit 571f8742 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

fixed celery config method

parent 527dca9b
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,8 @@ import os
import logging
from celery import Celery
from celery.exceptions import ImproperlyConfigured
from fractalis.config import file_to_dict
def get_scripts_packages():
......@@ -20,11 +21,13 @@ def get_scripts_packages():
packages.append(package)
return packages
app = Celery(__name__)
app.config_from_object('fractalis.config')
try:
app.config_from_envvar('FRACTALIS_CONFIG')
except ImproperlyConfigured:
config = file_to_dict(os.environ['FRACTALIS_CONFIG'])
app.conf.update(config)
except KeyError:
logger = logging.getLogger('fractalis')
logger.warning("FRACTALIS_CONFIG is not set. Using defaults.")
app.autodiscover_tasks(packages=get_scripts_packages())
......@@ -9,3 +9,12 @@ BROKER_URL = 'amqp://'
CELERY_RESULT_BACKEND = 'redis://{}:{}'.format(REDIS_HOST, REDIS_PORT)
PERMANENT_SESSION_LIFETIME = timedelta(days=1)
# DO NOT MODIFY THIS FILE!
def file_to_dict(abs_path):
config = {}
with open(abs_path) as f:
for line in f:
(key, value) = [s.strip() for s in line.split('=')]
config[key] = value
return config
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment