Commit 103b682a 103b682a4b4fd9c897156a09e242415c76582854 by wenxin

添加启停脚本

1 parent 9d77aaa9
1 #!/bin/bash
2
3 # 激活 conda 环境
4 eval "$(conda shell.bash hook)"
5 conda activate spider
6 # 切换到 app 目录
7 cd ./app || exit
8 # 后台运行 FastAPI 应用
9 nohup python main.py &
10 # 输出进程ID到文件,以便于后续停止服务时使用
11 echo $! > fastapi.pid
12 # 在启动之后输出pid文件中的进程ID
13 echo "怕从服务启动成功: $(cat fastapi.pid)"
...\ No newline at end of file ...\ No newline at end of file
1 #!/bin/bash
2
3 # 读取PID文件以获取进程ID
4 if [ -f fastapi.pid ]; then
5 PID=$(cat fastapi.pid)
6 echo "停止爬虫服务 PID->: $PID"
7 kill -9 $PID
8 # 删除PID文件
9 rm fastapi.pid
10 else
11 echo "未找到爬虫服务PID"
12 fi
13
14 echo "爬虫服务已停止"
...\ No newline at end of file ...\ No newline at end of file