Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ jobs:
pip install -r requirements.txt

- name: Check FastAPI Server
env:
REDIS_HOST: localhost
REDIS_PORT: 6379
run: |
uvicorn app.main:app --host 0.0.0.0 --port 8000 --log-level warning &
sleep 5
Expand Down
9 changes: 8 additions & 1 deletion app/utils/redis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import redis
import time
import os

redis_client = None # 全局 Redis 客户端变量

Expand All @@ -13,7 +14,13 @@ def get_redis_client():
while True:
try:
print("Connecting to Redis...")
redis_client = redis.StrictRedis(host='localhost', port=6379, db=0, decode_responses=True)
redis_client = redis.StrictRedis(
host=os.getenv("REDIS_HOST", "localhost"),
port=int(os.getenv("REDIS_PORT", 6379)),
password=os.getenv("REDIS_PASSWORD", None),
db=0,
decode_responses=True
)
redis_client.ping()
print("Connected to Redis successfully.")
break
Expand Down