From 84901345f00cd35d169eae98ec55c375809da4c0 Mon Sep 17 00:00:00 2001 From: KeithLin724 Date: Thu, 21 Dec 2023 14:15:45 +0800 Subject: [PATCH 1/3] add the g4f version --- api/requirements.txt | 2 +- api_cuda/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/requirements.txt b/api/requirements.txt index 5ec761c..a52c6b1 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -9,7 +9,7 @@ accelerate transformers httpx Pillow -g4f +g4f==0.1.8.8 diffusers scipy apscheduler diff --git a/api_cuda/requirements.txt b/api_cuda/requirements.txt index ab5be74..2403687 100644 --- a/api_cuda/requirements.txt +++ b/api_cuda/requirements.txt @@ -9,7 +9,7 @@ accelerate transformers httpx Pillow -g4f +g4f==0.1.8.8 diffusers scipy apscheduler From 4cceab35d08082989be8bd9b322d699e0bfa814c Mon Sep 17 00:00:00 2001 From: KeithLin724 Date: Thu, 21 Dec 2023 14:19:46 +0800 Subject: [PATCH 2/3] update the firewall port --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bccfda6..ba36c18 100644 --- a/README.md +++ b/README.md @@ -82,4 +82,13 @@ You need to make a`./chat/src/.env` ```sh SERVER_IP={your_server_ip} SERVER_PORT=5000 -``` \ No newline at end of file +``` +--- +## Firewall +You need to allow +|port|function| +|-|-| +|5000|main API| +|6379|redis Database| +|8001|redis Database Webpage Monitor| +|4080|Text-to-image API| From 2dfeb94d52be44713209387e039ee3e77a418c84 Mon Sep 17 00:00:00 2001 From: KeithLin724 Date: Fri, 22 Dec 2023 10:59:42 +0800 Subject: [PATCH 3/3] update with out using .env file --- README.md | 6 +++--- api/base/__init__.py | 10 ++++++---- api/compose.yaml | 15 ++++++++++----- api/rq_worker.py | 8 +++++--- api/server_data.json | 2 +- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ba36c18..872742b 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,12 @@ In `api_cuda` folder is a text_to_image server, for provide text to image servic ### Mention -You need to make a`./api/.env` and `./api_cuda/.env` -#### Format of `./api/.env` +You need to make `./api_cuda/.env` file + #### Format of `./api_cuda/.env` ```sh diff --git a/api/base/__init__.py b/api/base/__init__.py index 965b45e..a35e238 100644 --- a/api/base/__init__.py +++ b/api/base/__init__.py @@ -7,11 +7,12 @@ import logging from func import helper -from dotenv import load_dotenv +# from dotenv import load_dotenv -load_dotenv() +# load_dotenv() -REDIS_CONNECT = Redis(host=os.getenv("SERVER_IP"), port=6379) +# REDIS_CONNECT = Redis(host=os.getenv("SERVER_IP"), port=6379) +REDIS_CONNECT = Redis(host="redis", port=6379) TASK_IMAGE_QUEUE = Queue( "generate-image-queue", connection=REDIS_CONNECT, @@ -19,7 +20,8 @@ ) # SERVER_IP = helper.get_local_ip() -SERVER_IP = os.getenv("SERVER_IP") +# SERVER_IP = os.getenv("SERVER_IP") +SERVER_IP = "localhost" SERVER_PORT = 5000 SERVER_URL = f"http://{SERVER_IP}:{SERVER_PORT}" diff --git a/api/compose.yaml b/api/compose.yaml index ebb06ab..5185eb1 100644 --- a/api/compose.yaml +++ b/api/compose.yaml @@ -16,6 +16,8 @@ services: - redis_volume_data:/data ports: - 6379:6379 + networks: + - my-network redis_insight: image: redislabs/redisinsight:latest @@ -23,9 +25,12 @@ services: restart: always ports: - 8001:8001 + networks: + - my-network volumes: - redis_insight_volume_data:/db + server: runtime: nvidia # 使用 NVIDIA Container Toolkit build: @@ -45,8 +50,8 @@ services: environment: - NVIDIA_VISIBLE_DEVIVES=all - - SERVER_IP=${SERVER_IP} - - SERVER_PORT=${SERVER_PORT} + # - SERVER_IP=${SERVER_IP} + # - SERVER_PORT=${SERVER_PORT} work_listener: build: @@ -59,9 +64,9 @@ services: networks: - my-network - environment: - - SERVER_IP=${SERVER_IP} - - SERVER_PORT=${SERVER_PORT} + # environment: + # - SERVER_IP=${SERVER_IP} + # - SERVER_PORT=${SERVER_PORT} volumes: diff --git a/api/rq_worker.py b/api/rq_worker.py index 4375323..de66dd7 100644 --- a/api/rq_worker.py +++ b/api/rq_worker.py @@ -1,13 +1,15 @@ from rq import Worker, Queue, Connection from redis import Redis import os -from dotenv import load_dotenv + +# from dotenv import load_dotenv import api_task_func -load_dotenv() +# load_dotenv() -SERVER_IP = os.getenv("SERVER_IP") +# SERVER_IP = os.getenv("SERVER_IP") +SERVER_IP = "redis" # use in docker compose print(SERVER_IP) # 连接到Redis队列 redis_conn = Redis(host=SERVER_IP, port=6379) diff --git a/api/server_data.json b/api/server_data.json index 7f1a348..da6175b 100644 --- a/api/server_data.json +++ b/api/server_data.json @@ -1 +1 @@ -{"ip": "140.113.238.27", "port": 5000} \ No newline at end of file +{"ip": "localhost", "port": 5000} \ No newline at end of file