Beispiel #1
0
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.")
Beispiel #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