mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-02 20:59:06 +08:00
Add celery app instance with base config
This patch allows to schedule tasks and launch workers with basic
config. To launch a worker:
celery -A module_build_service.celery_app -l info
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
This commit is contained in:
@@ -92,6 +92,18 @@ class BaseConfiguration(object):
|
||||
# Disable Client Authorization
|
||||
NO_AUTH = False
|
||||
|
||||
# Configs for running tasks asynchronously with Celery
|
||||
# For details of Celery configs, refer to Celery documentation:
|
||||
# https://docs.celeryproject.org/en/latest/userguide/configuration.html
|
||||
#
|
||||
# Each config name consists of namespace CELERY_ and the new Celery config
|
||||
# name converted to upper case. For example the broker url, Celery config
|
||||
# name is broker_url, then as you can below, the corresponding config name
|
||||
# in MBS is CELERY_BROKER_URL.
|
||||
CELERY_BROKER_URL = ""
|
||||
CELERY_RESULT_BACKEND = ""
|
||||
CELERY_IMPORTS = []
|
||||
|
||||
|
||||
class TestConfiguration(BaseConfiguration):
|
||||
BUILD_LOGS_DIR = "/tmp"
|
||||
@@ -154,3 +166,6 @@ class OfflineLocalBuildConfiguration(LocalBuildConfiguration):
|
||||
class DevConfiguration(LocalBuildConfiguration):
|
||||
DEBUG = True
|
||||
LOG_BACKEND = "console"
|
||||
|
||||
CELERY_BROKER_URL = "redis://localhost:6379/0"
|
||||
CELERY_RESULT_BACKEND = "redis://localhost:6379/0"
|
||||
|
||||
@@ -43,6 +43,7 @@ RUN yum -y install \
|
||||
python-sqlalchemy \
|
||||
python-tox \
|
||||
python2-distro \
|
||||
python2-celery \
|
||||
python2-libmodulemd2 \
|
||||
python2-pyyaml \
|
||||
python2-pungi \
|
||||
|
||||
@@ -10,6 +10,7 @@ RUN dnf -y install \
|
||||
createrepo_c \
|
||||
rsync \
|
||||
python3-distro \
|
||||
python3-celery \
|
||||
python3-fedmsg \
|
||||
python3-kobo-rpmlib \
|
||||
python3-rpm \
|
||||
|
||||
@@ -19,10 +19,12 @@ for a number of tasks:
|
||||
"""
|
||||
|
||||
import pkg_resources
|
||||
from celery import Celery
|
||||
from flask import Flask, has_app_context, url_for
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from sqlalchemy.pool import StaticPool
|
||||
from logging import getLogger
|
||||
|
||||
import gi # noqa
|
||||
gi.require_version("Modulemd", "2.0") # noqa
|
||||
from gi.repository import Modulemd # noqa
|
||||
@@ -46,6 +48,15 @@ app.wsgi_app = ReverseProxy(app.wsgi_app)
|
||||
|
||||
conf = init_config(app)
|
||||
|
||||
celery_app = Celery("module-build-service")
|
||||
# Convert config names specific for Celery like this:
|
||||
# celery_broker_url -> broker_url
|
||||
celery_configs = {
|
||||
name[7:]: getattr(conf, name)
|
||||
for name in dir(conf) if name.startswith('celery_')
|
||||
}
|
||||
celery_app.conf.update(**celery_configs)
|
||||
|
||||
|
||||
class MBSSQLAlchemy(SQLAlchemy):
|
||||
"""
|
||||
|
||||
@@ -19,3 +19,4 @@ pyOpenSSL
|
||||
requests
|
||||
six
|
||||
sqlalchemy
|
||||
celery
|
||||
|
||||
Reference in New Issue
Block a user