def worker_supervisor(): """ Start worker supervisor. This program controls workers ran on the same machine. Also, it writes metric of resources consumption. """ host = socket.gethostname() logger = create_logger(_session, 'worker_supervisor') logger.info('worker_supervisor start', ComponentType.WorkerSupervisor, host) _create_computer() _create_docker() start_schedule([(stop_processes_not_exist, 10)]) if DOCKER_MAIN: syncer = FileSync() start_schedule([(worker_usage, 0)]) start_schedule([(syncer.sync, 0)]) name = f'{host}_{DOCKER_IMG}_supervisor' argv = [ 'worker', '--loglevel=INFO', '-P=solo', f'-n={name}', '-O fair', '-c=1', '--prefetch-multiplier=1', '-Q', f'{name}' ] logger.info('worker_supervisor run celery', ComponentType.WorkerSupervisor, host) app.worker_main(argv)
def worker(number): """ Start worker :param number: worker index """ name = f'{socket.gethostname()}_{DOCKER_IMG}' argv = [ 'worker', '--loglevel=INFO', '-P=solo', f'-n={name}_{number}', '-O fair', '-c=1', '--prefetch-multiplier=1', '-Q', f'{name},' f'{name}_{number}' ] app.worker_main(argv)