Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/celery_backend/config.py
Show All 12 Lines | |||||
from celery.utils.log import ColorFormatter | from celery.utils.log import ColorFormatter | ||||
from celery.worker.control import Panel | from celery.worker.control import Panel | ||||
from kombu import Exchange, Queue | from kombu import Exchange, Queue | ||||
from kombu.five import monotonic as _monotonic | from kombu.five import monotonic as _monotonic | ||||
import requests | import requests | ||||
from typing import Any, Dict | |||||
from swh.scheduler import CONFIG as SWH_CONFIG | from swh.scheduler import CONFIG as SWH_CONFIG | ||||
from swh.core.config import load_named_config, merge_configs | from swh.core.config import load_named_config, merge_configs | ||||
from swh.core.logger import JournalHandler | from swh.core.logger import JournalHandler | ||||
DEFAULT_CONFIG_NAME = 'worker' | DEFAULT_CONFIG_NAME = 'worker' | ||||
CONFIG_NAME_ENVVAR = 'SWH_WORKER_INSTANCE' | CONFIG_NAME_ENVVAR = 'SWH_WORKER_INSTANCE' | ||||
CONFIG_NAME_TEMPLATE = 'worker/%s' | CONFIG_NAME_TEMPLATE = 'worker/%s' | ||||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | def register_task_class(app, name, cls): | ||||
task_instance = cls() | task_instance = cls() | ||||
task_instance.name = name | task_instance.name = name | ||||
app.register_task(task_instance) | app.register_task(task_instance) | ||||
INSTANCE_NAME = os.environ.get(CONFIG_NAME_ENVVAR) | INSTANCE_NAME = os.environ.get(CONFIG_NAME_ENVVAR) | ||||
CONFIG_NAME = os.environ.get('SWH_CONFIG_FILENAME') | CONFIG_NAME = os.environ.get('SWH_CONFIG_FILENAME') | ||||
CONFIG = {} | CONFIG = {} # type: Dict[str, Any] | ||||
if CONFIG_NAME: | if CONFIG_NAME: | ||||
# load the celery config from the main config file given as | # load the celery config from the main config file given as | ||||
# SWH_CONFIG_FILENAME environment variable. | # SWH_CONFIG_FILENAME environment variable. | ||||
# This is expected to have a [celery] section in which we have the | # This is expected to have a [celery] section in which we have the | ||||
# celery specific configuration. | # celery specific configuration. | ||||
SWH_CONFIG.clear() | SWH_CONFIG.clear() | ||||
SWH_CONFIG.update(load_named_config(CONFIG_NAME)) | SWH_CONFIG.update(load_named_config(CONFIG_NAME)) | ||||
CONFIG = SWH_CONFIG.get('celery') | CONFIG = SWH_CONFIG.get('celery', default={}) | ||||
ardumont: jsyk, within docker-env, this does not work (after rebuild of the swh containers).
```
swh… | |||||
ardumontUnsubmitted Not Done Inline Actions
There we go D2059 ;) ardumont: > I'll open a diff.
There we go D2059 ;) | |||||
if not CONFIG: | if not CONFIG: | ||||
# otherwise, back to compat config loading mechanism | # otherwise, back to compat config loading mechanism | ||||
if INSTANCE_NAME: | if INSTANCE_NAME: | ||||
CONFIG_NAME = CONFIG_NAME_TEMPLATE % INSTANCE_NAME | CONFIG_NAME = CONFIG_NAME_TEMPLATE % INSTANCE_NAME | ||||
else: | else: | ||||
CONFIG_NAME = DEFAULT_CONFIG_NAME | CONFIG_NAME = DEFAULT_CONFIG_NAME | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |
jsyk, within docker-env, this does not work (after rebuild of the swh containers).
I'll open a diff.