예제 #1
0
#    http://www.apache.org/licenses/LICENSE-2.0
#
# No part of the project, including this file, may be copied,
# modified, propagated, or distributed except according to the
# terms contained in the LICENSE file.

import celery
import logging
import config.parser as config
from brain.helpers.celerytasks import route, async_call

results_app = celery.Celery('resultstasks')
config.conf_results_celery(results_app)

probe_app = celery.Celery('probetasks')
config.conf_probe_celery(probe_app)

log = logging.getLogger(__name__)


# ============
#  Task calls
# ============

def job_launch(ftpuser, filename, probename, task_id):
    """ send a task to the brain to flush the scan files"""
    log.debug("ftpuser %s filename %s probe %s" +
              " task_id %s",
              ftpuser, filename, probename, task_id)
    hook_success = route(
        results_app.signature("brain.results_tasks.job_success",
예제 #2
0
파일: tasks.py 프로젝트: vaginessa/irma
    def after_setup_logger_handler(sender=None, logger=None, loglevel=None,
                                   logfile=None, format=None,
                                   colorize=None, **kwds):
        config.setup_debug_logger(logging.getLogger(__name__))
        log.debug("debug is enabled")
    celery.signals.after_setup_logger.connect(after_setup_logger_handler)
    celery.signals.after_setup_task_logger.connect(after_setup_logger_handler)


# disable insecure serializer (disabled by default from 3.x.x)
if (kombu.VERSION.major) < 3:
    kombu.disable_insecure_serializers()

# declare a new Local Probe application
probe_app = Celery("probe.tasks")
config.conf_probe_celery(probe_app)
config.configure_syslog(probe_app)

# discover plugins located at specified path
plugin_path = os.path.abspath("modules")
if not os.path.exists(plugin_path):
    log.error("path {0} is invalid, cannot load probes".format(plugin_path))
    sys.exit(1)
manager = PluginManager()
manager.discover(plugin_path)

# determine dynamically queues to connect to using plugin names
probes = manager.get_all_plugins()
if not probes:
    log.error("No probe found, exiting application")
    sys.exit(1)