Skip to content

Commit e7344da

Browse files
committed
fix remove logs
1 parent f67149b commit e7344da

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ tests/
22
.vscode/
33
.venv/
44
__pycache__/
5-
*.log*
5+
*.log*
6+
logs/

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.vscode/
22
__pycache__/
33
*.log*
4-
test/
4+
test/
5+
logs/

Dockerfile.copy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM gpt_server:v0.2
1+
FROM gpt_server:v0.2.1
22

33
COPY ./ /gpt_server
44

gpt_server/serving/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
original_pythonpath = os.environ.get("PYTHONPATH", "")
1717
os.environ["PYTHONPATH"] = original_pythonpath + ":" + root_dir
1818
sys.path.append(root_dir)
19+
os.environ["LOGDIR"] = os.path.join(root_dir, "./logs")
1920
from gpt_server.utils import (
2021
start_server,
2122
start_api_server,

gpt_server/utils.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ def start_openai_server(host, port):
2525
openai_server_process = Process(target=run_cmd, args=(cmd,))
2626
openai_server_process.start()
2727

28+
2829
def start_api_server(host: str = "0.0.0.0", port: int = 8081):
2930
cmd = f"python -m gpt_server.serving.start_api_server --host {host} --port {port}"
3031
start_server_process = Process(target=run_cmd, args=(cmd,))
3132
start_server_process.start()
32-
33+
3334

3435
def start_server(host: str = "0.0.0.0", port: int = 8081):
3536
"""启动服务"""
@@ -65,15 +66,12 @@ def stop_server():
6566

6667

6768
def delete_log(root_path):
68-
scipt_path = os.path.join(root_path, "gpt_server/script")
69-
serving_path = os.path.join(root_path, "gpt_server/serving")
70-
71-
serving_path_datanames = os.listdir(serving_path) # 查找本目录下所有文件
72-
scipt_path_datanames = os.listdir(scipt_path)
73-
datanames = serving_path_datanames + scipt_path_datanames
69+
logs_path = os.environ.get("LOGDIR")
70+
logs_path_datanames = os.listdir(logs_path) # 查找本目录下所有文件
71+
datanames = logs_path_datanames
7472
for dataname in datanames:
7573
if dataname.endswith(".log"):
76-
os.remove(os.path.join(serving_path, f"{dataname}"))
74+
os.remove(os.path.join(logs_path, f"{dataname}"))
7775

7876

7977
def get_free_tcp_port():

0 commit comments

Comments
 (0)