예제 #1
0
파일: router.py 프로젝트: jmoon1506/merlin
def monitor_workers(task_server, sleep_duration):
    """
    Monitor for running clery workers to keep an allocation alive.

    :param `task_server`: The task server for which to monitor workers.
    """
    if task_server == "celery":
        while is_running("celery worker"):
            LOG.info("Monitor: celery workers are running.")
            time.sleep(sleep_duration)
        LOG.info("Monitor: celery workers are not running.")
예제 #2
0
def get_running_queues():
    """
    Check for running celery workers with -Q queues
    and return a unique list of the queues

    Must be run on the allocation where the workers are running
    """
    running_queues = []

    if not is_running("celery worker"):
        return running_queues

    procs = get_procs("celery")
    for _, lcmd in procs:
        lcmd = list(filter(None, lcmd))
        cmdline = " ".join(lcmd)
        if "-Q" in cmdline:
            running_queues.extend(lcmd[lcmd.index("-Q") + 1].split(","))

    running_queues = list(set(running_queues))

    return running_queues