1
This commit is contained in:
@@ -59,34 +59,12 @@
|
|||||||
```bash
|
```bash
|
||||||
# 在本地打包必需文件(WSL或Git Bash)
|
# 在本地打包必需文件(WSL或Git Bash)
|
||||||
cd /mnt/e/50425/Documents/Github/GPA_Monitoring
|
cd /mnt/e/50425/Documents/Github/GPA_Monitoring
|
||||||
|
|
||||||
# 创建压缩包(只包含必需文件)
|
|
||||||
tar -czf gpa_monitor.tar.gz \
|
|
||||||
monitor.py \
|
|
||||||
config.ini \
|
|
||||||
requirements.txt \
|
|
||||||
setup_python.sh \
|
|
||||||
diagnose.sh \
|
|
||||||
grade-monitor.service \
|
|
||||||
README.md
|
|
||||||
|
|
||||||
# 查看压缩包内容
|
|
||||||
tar -tzf gpa_monitor.tar.gz
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 第二步:上传到服务器
|
### 第二步:上传到服务器
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 方法1:使用 scp
|
|
||||||
scp gpa_monitor.tar.gz 用户名@服务器IP:/home/用户名/
|
scp gpa_monitor.tar.gz 用户名@服务器IP:/home/用户名/
|
||||||
|
|
||||||
# 方法2:使用 rsync(推荐)
|
|
||||||
rsync -avz gpa_monitor.tar.gz 用户名@服务器IP:/home/用户名/
|
|
||||||
|
|
||||||
# 方法3:使用 sftp
|
|
||||||
sftp 用户名@服务器IP
|
|
||||||
put gpa_monitor.tar.gz
|
|
||||||
exit
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 第三步:在服务器上解压并安装
|
### 第三步:在服务器上解压并安装
|
||||||
@@ -95,10 +73,7 @@ exit
|
|||||||
# 登录到服务器
|
# 登录到服务器
|
||||||
ssh 用户名@服务器IP
|
ssh 用户名@服务器IP
|
||||||
|
|
||||||
# 解压文件
|
cd grade_monitor # 你解压到的目录
|
||||||
cd ~
|
|
||||||
tar -xzf gpa_monitor.tar.gz
|
|
||||||
cd grade_monitor # 或者你解压到的目录
|
|
||||||
|
|
||||||
# 给脚本添加执行权限
|
# 给脚本添加执行权限
|
||||||
chmod +x setup_python.sh diagnose.sh
|
chmod +x setup_python.sh diagnose.sh
|
||||||
@@ -154,7 +129,7 @@ cat .last_grade_content.txt
|
|||||||
|
|
||||||
## 🔧 设置后台运行
|
## 🔧 设置后台运行
|
||||||
|
|
||||||
### 方案A:使用 systemd(推荐,生产环境)
|
### 使用 systemd(推荐,生产环境)
|
||||||
|
|
||||||
**优点:** 开机自启、崩溃自动重启、系统化管理
|
**优点:** 开机自启、崩溃自动重启、系统化管理
|
||||||
|
|
||||||
@@ -207,47 +182,6 @@ sudo systemctl enable grade-monitor
|
|||||||
sudo systemctl disable grade-monitor
|
sudo systemctl disable grade-monitor
|
||||||
```
|
```
|
||||||
|
|
||||||
### 方案B:使用 tmux(简单易用)
|
|
||||||
|
|
||||||
**优点:** 简单、可随时查看输出、适合测试阶段
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 1. 安装 tmux(如果没有)
|
|
||||||
sudo apt update && sudo apt install tmux
|
|
||||||
|
|
||||||
# 2. 创建会话并运行
|
|
||||||
tmux new -s grade_monitor
|
|
||||||
source venv/bin/activate
|
|
||||||
python3 monitor.py
|
|
||||||
|
|
||||||
# 3. 离开会话(程序继续运行)
|
|
||||||
# 按 Ctrl+B,然后按 D
|
|
||||||
|
|
||||||
# 4. 重新连接查看
|
|
||||||
tmux attach -t grade_monitor
|
|
||||||
|
|
||||||
# 5. 查看所有会话
|
|
||||||
tmux ls
|
|
||||||
|
|
||||||
# 6. 关闭会话
|
|
||||||
tmux kill-session -t grade_monitor
|
|
||||||
```
|
|
||||||
|
|
||||||
### 方案C:使用 nohup(最简单)
|
|
||||||
|
|
||||||
**优点:** 快速、无需额外工具
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 后台运行
|
|
||||||
source venv/bin/activate
|
|
||||||
nohup python3 monitor.py > output.log 2>&1 &
|
|
||||||
|
|
||||||
# 查看进程
|
|
||||||
ps aux | grep monitor.py
|
|
||||||
|
|
||||||
# 停止程序
|
|
||||||
pkill -f monitor.py
|
|
||||||
```
|
|
||||||
|
|
||||||
## 📊 监控和维护
|
## 📊 监控和维护
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user