"""Redis 연결 · FILE_STORAGE db · RQ 워커 등록 상태.""" import os import django os.environ.setdefault("DJANGO_SETTINGS_MODULE", "alpha.settings") django.setup() import django_rq # noqa: E402 from rq import Worker # noqa: E402 from alpha.___db.redis.redis import connect_redis_file_store, connect_redis_web_cache # noqa: E402 # RQ 큐는 같은 Redis 의 서로 다른 DB 를 쓴다 (default=0, high=1, log=2). # 워커 등록도 DB 별로 나뉘므로 큐마다 그 큐의 커넥션으로 조회해야 한다. total_workers = 0 for name in ("default", "high", "log"): q = django_rq.get_queue(name) conn = django_rq.get_connection(name) workers = [w for w in Worker.all(connection=conn) if name in {qq.name for qq in w.queues}] total_workers += len(workers) print("QUEUE %-8s db=%s len=%-4s workers=%d" % (name, conn.connection_pool.connection_kwargs.get("db"), len(q), len(workers))) for w in workers: print(" %s queues=%s state=%s" % (w.name, ",".join(qq.name for qq in w.queues), w.get_state())) # 문서 원본 blob 이 오가는 db(3). alpha-processing 이 여기서 파일을 읽는다. connect_redis_file_store().ping() print("FILE_STORAGE=ok") connect_redis_web_cache().ping() print("WEB_CACHE=ok") print("WORKERS=%d" % total_workers)