소스 정보
- 저장소
- toly1994328/flash_im_by_ai
- 최근 소스 활동
- 2026년 6월 19일 00:11
- 감지된 SKILL.md 언어
- 중국어
- 스타
- 12
- 포크
- 2
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
SKILL.md 표시 중
SKILL.md
소스 지침 · 읽기 전용 미리보기- name
- server-operations
- description
- 后端服务启动与数据库操作规范。在需要启动后端服务、运行 API 测试、执行数据库迁移或遇到连接错误时激活,确保使用正确的命令和流程。
- metadata
- {"model":"manual","last_modified":"Wed, 18 Jun 2026 00:00:00 GMT"}
# 后端服务操作
## 适用场景
- 需要启动后端服务时
- 运行 API 测试脚本前
- 执行数据库迁移时
- 遇到 `PoolTimedOut`、`Connection refused` 等连接错误时
## 启动后端服务
**永远使用** `python scripts/server/start.py`,**禁止直接 `cargo run`**。
该脚本自动处理:PostgreSQL 启动 → 停旧进程 → cargo build → cargo run。
### 操作步骤
```python
# 1. 启动(长时间运行命令)
control_pwsh_process(action="start", command="python scripts/server/start.py", cwd="项目根目录绝对路径")
# 2. 等待启动完成
execute_pwsh(command="Start-Sleep -Seconds 10")
# 3. 验证成功(确认输出含 "listening on")
get_process_output(terminalId=xxx, lines=10)
```
### 启动失败排查
| 现象 | 原因 | 解法 |
|------|------|------|
| `PoolTimedOut` | PostgreSQL 没启动 | start.py 自动处理,检查日志 |
| `Failed to remove exe` | 旧进程锁文件 | start.py 自动 taskkill |
| 端口 9600 占用 | 旧进程未退出 | start.py 自动停止 |
## 停止服务
```python
control_pwsh_process(action="stop", terminalId=xxx)
```
## 数据库操作
```bash
# 执行单个迁移
$env:PGPASSWORD="postgres"; psql -h localhost -U postgres -d flash_im -f "server/migrations/xxx.sql"
# 重置数据库
python scripts/server/reset_db.py
# 查询数据
$env:PGPASSWORD="postgres"; psql -h localhost -U postgres -d flash_im -c "SELECT ..."
```
## 注意事项
- ❌ 禁止 `cargo run`(不启动 PostgreSQL)
- ❌ 禁止在 start.py 之前手动 `cargo build`
- ✅ 测试脚本运行前必须确认服务已就绪
- ✅ 启动后等待 10 秒再做任何请求
GitHub에서 보기