diff --git a/Dockerfile b/Dockerfile index 23e7990..4565969 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,2 @@ FROM python:3.11-slim -RUN pip install python-binance aiokafka aioredis py-spy uvloop +RUN pip install python-binance aiokafka aioredis py-spy uvloop loguru dynaconf diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4bdfa22 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + data-collect: + network_mode: host + build: . + command: python main.py + extra_hosts: + - redpanda-0:10.0.0.139 + volumes: + - .:/app + working_dir: /app diff --git a/kafka_service.py b/kafka_service.py index 738d768..4facfcc 100644 --- a/kafka_service.py +++ b/kafka_service.py @@ -1,7 +1,8 @@ from aiokafka import AIOKafkaProducer - +import os +kafka_nodes = os.environ.get("kafka.nodes","redpanda-0:19092") # Kafka 配置 -KAFKA_BOOTSTRAP_SERVERS = '127.0.0.1:19092' +KAFKA_BOOTSTRAP_SERVERS = kafka_nodes # KAFKA_TOPIC = 'binance_agg_trade' class KafkaProducerSingleton: @@ -54,4 +55,4 @@ async def send_to_kafka(topic, data, key=None, send_now=False): producer = await _kafka_producer_singleton.get_producer2() else: producer = await _kafka_producer_singleton.get_producer() - await producer.send(topic, data,key=key) \ No newline at end of file + await producer.send(topic, data,key=key) diff --git a/main.py b/main.py index 75e2b69..d47b92d 100644 --- a/main.py +++ b/main.py @@ -4,8 +4,8 @@ import asyncio from comsumer import bn_agg_trade, order async def main(): a1 = bn_agg_trade.main() - a2 = order.start() - res = asyncio.gather(a1, a2) + # a2 = order.start() + res = asyncio.gather(a1) await res if __name__ == "__main__":