更新启动文件
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,2 +1,3 @@
 | 
				
			|||||||
__pycache__
 | 
					__pycache__
 | 
				
			||||||
.env
 | 
					.env
 | 
				
			||||||
 | 
					venv
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								main.py
									
									
									
									
									
								
							@@ -6,7 +6,7 @@ import uvicorn
 | 
				
			|||||||
from fastapi import FastAPI
 | 
					from fastapi import FastAPI
 | 
				
			||||||
from starlette.middleware.cors import CORSMiddleware
 | 
					from starlette.middleware.cors import CORSMiddleware
 | 
				
			||||||
from functools import lru_cache
 | 
					from functools import lru_cache
 | 
				
			||||||
from routers import reverse, user, task, img, user_collect
 | 
					from routers import reverse, user, task, img, user_collect, webhook
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 初始化 FastAPI
 | 
					# 初始化 FastAPI
 | 
				
			||||||
@@ -20,6 +20,7 @@ app.include_router(task.router, prefix='/api/task', tags=['任务'])
 | 
				
			|||||||
app.include_router(reverse.router, prefix='/api/default', tags=['搜图'])
 | 
					app.include_router(reverse.router, prefix='/api/default', tags=['搜图'])
 | 
				
			||||||
app.include_router(user_collect.router, prefix='/api/user_collect', tags=['收藏'])
 | 
					app.include_router(user_collect.router, prefix='/api/user_collect', tags=['收藏'])
 | 
				
			||||||
app.include_router(img.router, prefix='/imgs', tags=['图片'])
 | 
					app.include_router(img.router, prefix='/imgs', tags=['图片'])
 | 
				
			||||||
 | 
					app.include_router(webhook.router, prefix='/api/webhook', tags=['webhook'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 启动服务
 | 
					# 启动服务
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										20
									
								
								routers/webhook.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								routers/webhook.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					import os
 | 
				
			||||||
 | 
					from fastapi import APIRouter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					router = APIRouter()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 获取标准原尺寸图
 | 
				
			||||||
 | 
					@router.get("", summary="webhook", description="自动更新")
 | 
				
			||||||
 | 
					def webhook():
 | 
				
			||||||
 | 
					    print("webhook")
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # 执行 Bash 命令
 | 
				
			||||||
 | 
					    exit_code = os.system('git pull')
 | 
				
			||||||
 | 
					    print('Exit code:', exit_code)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    exit_code = os.system('npm restart reverse-5002')
 | 
				
			||||||
 | 
					    print('Exit code:', exit_code)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return {"code": 200, "msg": "success"}
 | 
				
			||||||
							
								
								
									
										8
									
								
								start.sh
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								start.sh
									
									
									
									
									
								
							@@ -1,13 +1,17 @@
 | 
				
			|||||||
#!/bin/sh
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 创建虚拟环境 Python 3.10.12
 | 
				
			||||||
 | 
					cd ~/reverse_image_search_gpu
 | 
				
			||||||
 | 
					python3.10 -m venv venv
 | 
				
			||||||
 | 
					source venv/bin/activate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 安装依赖(使用清华镜像)
 | 
					# 安装依赖(使用清华镜像)
 | 
				
			||||||
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
 | 
					pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 启动服务
 | 
					# 启动服务
 | 
				
			||||||
cd ~/reverse_image_search_gpu
 | 
					pm2 start python3 --name reverse-5002 -- main.py 5002
 | 
				
			||||||
pm2 start python3 --name reverse_image_search_gpu -- main.py 5002
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# pip freeze > requirements.txt
 | 
					# pip freeze > requirements.txt
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user