From 4e9a03eb216dd12c52e0d2630eea7103a18633e6 Mon Sep 17 00:00:00 2001 From: AKW <2497744746@qq.com> Date: Fri, 22 Dec 2023 14:23:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E8=B0=83=E7=8A=B6=E6=80=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/msg/utils.py | 9 ++++++--- docker-compose.yml | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/msg/utils.py b/apps/msg/utils.py index e72c83f..2f83856 100644 --- a/apps/msg/utils.py +++ b/apps/msg/utils.py @@ -1,5 +1,6 @@ import json import logging +import os from redis import Redis from django.conf import settings @@ -22,7 +23,8 @@ class JQRMSGPubSubUtils: def listen(): - logger.info('监听消息队列-----') + api = os.environ.get('api') + logger.info(f'监听消息队列-----{api}') from apps.jqr.serializers import TbMessageModelSerializer while True: data = JQRMSGPubSubUtils.rc.brpop(Constant.JQR_MSG_PUBSUB_CHANNEL, 5) @@ -41,5 +43,6 @@ def listen(): JQRMSGPubSubUtils.msg_list.clear() -t = Thread(target=listen) -t.start() +if not settings.DEBUG: + t = Thread(target=listen) + t.start() diff --git a/docker-compose.yml b/docker-compose.yml index ee4769d..7fc8d57 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,8 @@ services: context: . dockerfile: ./Dockerfile command: ./start + environment: + - api=true volumes: - .:/app ports: