Skip to content

Commit

Permalink
Merge pull request #14 from KeithLin724/KY_v1.0.0-dev
Browse files Browse the repository at this point in the history
KY_v1.0.0-dev
  • Loading branch information
KeithLin724 authored Dec 22, 2023
2 parents 42311fc + 2dfeb94 commit ae3aa5d
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 19 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/.env`
```sh
SERVER_IP={your_server_ip}
SERVER_PORT=5000
```
``` -->

#### Format of `./api_cuda/.env`
```sh
Expand Down Expand Up @@ -82,4 +82,13 @@ You need to make a`./chat/src/.env`
```sh
SERVER_IP={your_server_ip}
SERVER_PORT=5000
```
```
---
## Firewall
You need to allow
|port|function|
|-|-|
|5000|main API|
|6379|redis Database|
|8001|redis Database Webpage Monitor|
|4080|Text-to-image API|
10 changes: 6 additions & 4 deletions api/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@
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,
default_timeout=3600,
)

# 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}"

Expand Down
15 changes: 10 additions & 5 deletions api/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ services:
- redis_volume_data:/data
ports:
- 6379:6379
networks:
- my-network

redis_insight:
image: redislabs/redisinsight:latest
container_name: redis_insight
restart: always
ports:
- 8001:8001
networks:
- my-network
volumes:
- redis_insight_volume_data:/db


server:
runtime: nvidia # 使用 NVIDIA Container Toolkit
build:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ accelerate
transformers
httpx
Pillow
g4f
g4f==0.1.8.8
diffusers
scipy
apscheduler
Expand Down
8 changes: 5 additions & 3 deletions api/rq_worker.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api/server_data.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"ip": "140.113.238.27", "port": 5000}
{"ip": "localhost", "port": 5000}
2 changes: 1 addition & 1 deletion api_cuda/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ accelerate
transformers
httpx
Pillow
g4f
g4f==0.1.8.8
diffusers
scipy
apscheduler
Expand Down

0 comments on commit ae3aa5d

Please sign in to comment.