Browse Source

进一步完善

leon 1 tuần trước cách đây
mục cha
commit
1922be8348
6 tập tin đã thay đổi với 65 bổ sung1 xóa
  1. 36 0
      Makefile
  2. 24 0
      Readme.md
  3. 0 0
      asserts/.gitkeep
  4. 0 0
      log/.gitkeep
  5. 0 0
      models/.gitkeep
  6. 5 1
      server.py

+ 36 - 0
Makefile

@@ -0,0 +1,36 @@
+start:
+	@cd server && \
+	gunicorn -w 2 -b 0.0.0.0:18000 -k uvicorn.workers.UvicornWorker server:app --daemon
+	@sleep 1s
+	@ps -ef | grep gunicorn
+
+stop:
+	@pkill -f gunicorn
+	@sleep 1s
+	@ps -ef | grep gunicorn 
+
+restart: 
+	stop 
+	start
+
+status:
+	@ps -ef | grep gunicorn 
+
+debug:
+	@cd server && \
+	python3 server.py
+
+
+log:
+	@tail -f log/runtime.log
+
+help:
+	@echo "make start   => start server"
+	@echo "make stop    => stop server"
+	@echo "make restart => restart server"
+	@echo "make status  => check server status"
+	@echo "make debug   => python3 server.py"
+	@echo "make log     => print log"
+	@echo "make help    => help"
+
+.PHONY: start stop restart status debug help log

+ 24 - 0
Readme.md

@@ -0,0 +1,24 @@
+## 大模型服务框架
+
+
+### 服务相关命令
+`make start`
+开启服务
+
+`make stop`
+关闭服务
+
+`make restart`
+重启服务
+
+`make status`
+查看服务进程
+
+`make debug`
+命令行启动服务
+
+`make log`
+查看日志
+
+`make help`
+查看相关命令

+ 0 - 0
asserts/.gitkeep


+ 0 - 0
log/.gitkeep


+ 0 - 0
models/.gitkeep


+ 5 - 1
server.py

@@ -2,6 +2,7 @@ from pydantic import BaseModel, field_validator, model_validator, Field
 from typing import List, Optional, Generic, TypeVar
 from utils import base64_to_cv2
 from fastapi import FastAPI
+import uvicorn
 
 app = FastAPI()
 
@@ -37,4 +38,7 @@ async def detect(item: APIRequest):
     # 大模型检测后如果有违章
     # response["data"]["illegal"] = 1
     
-    return response
+    return response
+
+if __name__ == "__main__":
+    uvicorn.run('server:app', host="0.0.0.0", port=18000)