Skip to content

Commit

Permalink
fix remove logs
Browse files Browse the repository at this point in the history
  • Loading branch information
shell-nlp committed May 20, 2024
1 parent f67149b commit e7344da
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ tests/
.vscode/
.venv/
__pycache__/
*.log*
*.log*
logs/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/
__pycache__/
*.log*
test/
test/
logs/
2 changes: 1 addition & 1 deletion Dockerfile.copy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gpt_server:v0.2
FROM gpt_server:v0.2.1

COPY ./ /gpt_server

Expand Down
1 change: 1 addition & 0 deletions gpt_server/serving/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
original_pythonpath = os.environ.get("PYTHONPATH", "")
os.environ["PYTHONPATH"] = original_pythonpath + ":" + root_dir
sys.path.append(root_dir)
os.environ["LOGDIR"] = os.path.join(root_dir, "./logs")
from gpt_server.utils import (
start_server,
start_api_server,
Expand Down
14 changes: 6 additions & 8 deletions gpt_server/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ def start_openai_server(host, port):
openai_server_process = Process(target=run_cmd, args=(cmd,))
openai_server_process.start()


def start_api_server(host: str = "0.0.0.0", port: int = 8081):
cmd = f"python -m gpt_server.serving.start_api_server --host {host} --port {port}"
start_server_process = Process(target=run_cmd, args=(cmd,))
start_server_process.start()


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


def delete_log(root_path):
scipt_path = os.path.join(root_path, "gpt_server/script")
serving_path = os.path.join(root_path, "gpt_server/serving")

serving_path_datanames = os.listdir(serving_path) # 查找本目录下所有文件
scipt_path_datanames = os.listdir(scipt_path)
datanames = serving_path_datanames + scipt_path_datanames
logs_path = os.environ.get("LOGDIR")
logs_path_datanames = os.listdir(logs_path) # 查找本目录下所有文件
datanames = logs_path_datanames
for dataname in datanames:
if dataname.endswith(".log"):
os.remove(os.path.join(serving_path, f"{dataname}"))
os.remove(os.path.join(logs_path, f"{dataname}"))


def get_free_tcp_port():
Expand Down

0 comments on commit e7344da

Please sign in to comment.