Skip to content

Commit 61dbd95

Browse files
authored
Merge pull request #34 from BUAA-SE-coders007/fix/30
Fix/30
2 parents 8ce0d2e + 0b958b9 commit 61dbd95

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.github/workflows/check.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ jobs:
5050
pip install -r requirements.txt
5151
5252
- name: Check FastAPI Server
53-
env:
54-
REDIS_HOST: localhost
55-
REDIS_PORT: 6379
5653
run: |
5754
uvicorn app.main:app --host 0.0.0.0 --port 8000 --log-level warning &
5855
sleep 5

app/utils/redis.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import redis
22
import time
3+
import os
34

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

@@ -13,7 +14,13 @@ def get_redis_client():
1314
while True:
1415
try:
1516
print("Connecting to Redis...")
16-
redis_client = redis.StrictRedis(host='localhost', port=6379, db=0, decode_responses=True)
17+
redis_client = redis.StrictRedis(
18+
host=os.getenv("REDIS_HOST", "localhost"),
19+
port=int(os.getenv("REDIS_PORT", 6379)),
20+
password=os.getenv("REDIS_PASSWORD", None),
21+
db=0,
22+
decode_responses=True
23+
)
1724
redis_client.ping()
1825
print("Connected to Redis successfully.")
1926
break

0 commit comments

Comments
 (0)