unis_manager/scripts/README.md

37 lines
1.7 KiB
Markdown
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# scripts/ 目录说明
运维 / 启动脚本统一收在这里。所有脚本都自带 `cd 项目根目录`,在哪个目录执行都可以。
## 启动与部署
| 文件 | 用途 |
|---|---|
| `run.sh` | 本地启动。自动检查 Python 3.10+、创建 `.venv`、缺依赖自动 `pip install`(默认源失败会切国内镜像)、缺 `.env` 从 `.env.example` 生成、首次运行建库,然后起 uvicorn |
| `deploy.sh` | Docker 部署。`up` / `update` / `restart` / `down` / `logs` / `status` / `backup` / `mirror`;缺 docker / compose 时按 `AUTO_INSTALL=1` 尝试安装并拉起守护进程 |
```bash
./scripts/run.sh # 本地启动(默认热更新)
PORT=8771 ./scripts/run.sh # 换端口
AUTO_INSTALL=0 ./scripts/run.sh # 只检查环境,不自动安装
./scripts/deploy.sh up # Docker 构建 + 后台启动
./scripts/deploy.sh logs # 跟踪日志
```
## 数据导入(按需手动执行)
| 文件 | 用途 |
|---|---|
| `init_db.py` | 建表 + 预置分类(幂等,`run.sh` / 容器启动会自动调用) |
| `import_excel.py` | 导入《软件开发部管理工作执行表.xlsx》 |
| `import_staff.py` | 导入《软件开发部人员名单.xlsx》 |
| `import_custom_ledger.py` | 导入《定开项目.xlsx》市场台账(`--dry-run` 预演) |
> 导入脚本不传路径时,默认读 `data/import/` 下的同名文件;
> 也可以用 `XLSX` / `STAFF_XLSX` / `CUSTOM_LEDGER_XLSX` 环境变量或命令行参数指定。
## legacy/(历史一次性脚本)
旧数据修复 / 迁移脚本,**不参与启动流程**,也不需要放进 Docker 镜像。
只有遇到对应的历史数据问题时才手动执行,详见 [`legacy/README.md`](legacy/README.md)。