Files
aitsc/(红头)启动和停止.txt
rjb 1a87798b8a
Some checks failed
Flask 提示词大师 - CI/CD 流水线 / 代码质量检查 (push) Has been cancelled
Flask 提示词大师 - CI/CD 流水线 / 单元测试 (push) Has been cancelled
Flask 提示词大师 - CI/CD 流水线 / 集成测试 (push) Has been cancelled
Flask 提示词大师 - CI/CD 流水线 / 构建Docker镜像 (push) Has been cancelled
Flask 提示词大师 - CI/CD 流水线 / 部署到测试环境 (push) Has been cancelled
Flask 提示词大师 - CI/CD 流水线 / 部署到生产环境 (push) Has been cancelled
Flask 提示词大师 - CI/CD 流水线 / 部署监控系统 (push) Has been cancelled
temp
2026-02-23 17:50:22 +08:00

166 lines
3.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 提示词大师项目 - 服务器启动和停止指南
## 🚀 **启动服务器**
### 方法一:使用完整命令启动
```bash
# 进入项目目录
cd /home/renjianbo/aitsc
# 激活conda环境并启动服务
eval "$(/home/renjianbo/miniconda3/bin/conda shell.bash hook)" && conda activate myenv && gunicorn -c gunicorn.conf.py run_dev:app
```
### 方法二:分步启动
```bash
# 1. 进入项目目录
cd /home/renjianbo/aitsc
# 2. 激活conda环境
eval "$(/home/renjianbo/miniconda3/bin/conda shell.bash hook)"
conda activate myenv
# 3. 启动Gunicorn服务
gunicorn -c gunicorn.conf.py run_dev:app
```
### 方法三:后台启动
```bash
# 后台启动服务
nohup gunicorn -c gunicorn.conf.py run_dev:app > logs/gunicorn.log 2>&1 &
```
## 🛑 **停止服务器**
### 方法一使用PID文件停止
```bash
# 停止服务如果存在PID文件
kill -TERM $(cat logs/gunicorn.pid)
```
### 方法二强制停止所有Gunicorn进程
```bash
# 强制停止所有gunicorn进程
pkill -9 -f gunicorn
```
### 方法三:停止特定项目进程
```bash
# 停止run_dev:app相关进程
pkill -f "run_dev:app"
```
## 🔍 **检查服务状态**
### 检查进程状态
```bash
# 查看Gunicorn进程
ps aux | grep "run_dev:app" | grep -v grep
# 查看所有Gunicorn进程
ps aux | grep gunicorn | grep -v grep
```
### 检查端口状态
```bash
# 检查5002端口是否被监听
ss -tlnp | grep :5002
# 或者使用netstat
netstat -tlnp | grep :5002
```
### 检查服务响应
```bash
# 测试服务是否正常响应
curl -s http://localhost:5002/ | head -10
# 测试特定页面
curl -s -o /dev/null -w "%{http_code}" http://localhost:5002/admin/analytics_admin/
```
## 📊 **查看日志**
### 查看错误日志
```bash
# 查看最新的错误日志
tail -f logs/gunicorn_error.log
# 查看应用日志
tail -f logs/app.log
```
### 查看访问日志
```bash
# 查看访问日志
tail -f logs/gunicorn_access.log
```
## 🔧 **故障排除**
### 清理和重启
```bash
# 1. 停止所有相关进程
pkill -f gunicorn
# 2. 删除PID文件
rm -f logs/gunicorn.pid
# 3. 重新启动
eval "$(/home/renjianbo/miniconda3/bin/conda shell.bash hook)" && conda activate myenv && gunicorn -c gunicorn.conf.py run_dev:app
```
### 检查依赖
```bash
# 检查Python环境
which python
python --version
# 检查已安装的包
pip list | grep -E "(flask|gunicorn|openai)"
```
## 🌐 **访问地址**
启动成功后,可以访问以下地址:
- **本机浏览器**:使用 `http://localhost:5002/` 或 `http://127.0.0.1:5002/`
- **其他电脑/手机访问**:必须使用**服务器 IP**,不能使用 localhostlocalhost 指向访问者本机,会连接失败)
- **主页**`http://101.43.95.130:5002/`
- **饭菜规划**`http://101.43.95.130:5002/meal-planning`
- **古诗词解析**`http://101.43.95.130:5002/poetry/`
- **古诗词示例**`http://101.43.95.130:5002/poetry/examples`
- **后台管理**`http://101.43.95.130:5002/admin`
- **数据分析**`http://101.43.95.130:5002/admin/analytics_admin/`
## ✅ **启动成功的标志**
看到以下信息表示启动成功:
- `[INFO] 应用启动`
- `[INFO] 工作进程 X 已启动`
- `[INFO] 工作进程 X 初始化完成`
- 端口5002开始监听
## 📝 **项目信息**
- **项目名称**:提示词大师
- **功能描述**:智能生成高质量提示词,提升您的工作效率
- **技术栈**Python 3.12 + Flask + Gunicorn + MySQL
- **端口**5002
- **环境**conda myenv
- **配置文件**gunicorn.conf.py
- **启动文件**run_dev.py
## 🚨 **注意事项**
1. 确保conda环境已正确激活
2. 确保所有依赖包已安装
3. 确保数据库连接正常
4. 确保5002端口未被占用
5. 定期检查日志文件大小,避免磁盘空间不足
---
*最后更新2025-09-14*
*维护人员:系统管理员*