mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-28 05:46:36 +08:00
600a7acdfb
- 删除未经验证的环境要求(Docker 版本号、浏览器条目)与括号废话 - 故障排查改为真实处理路径(升级→重新发布→强制同步→重建 Agent→提交 issue),删除仅开发时用的排障章节 - 删除设计文档中的测试与验收、实现检查清单、贡献者阅读建议等开发内容 - 修正与代码不符的事实:reset-passwd 命令名、证书续签窗口 7 天、Pages 检查间隔 1440 分钟、Relay vhost 端口 8080、SSO 仅支持 OIDC 等 - 去除口语化表述与无意义括号,改写「不是…而是…」句式 - 同步修正文档站链接锚点,构建验证通过
168 lines
2.6 KiB
Markdown
168 lines
2.6 KiB
Markdown
# 命令与脚本
|
||
|
||
你会学到:OpenFlare Server、管理端前端、Agent、Relay、OpenFlared、Swagger 和文档站的常用启动、构建、测试、安装与卸载命令。
|
||
|
||
> 所有命令均在**仓库根目录**执行,除非另有说明。
|
||
|
||
## Server
|
||
|
||
源码启动:
|
||
|
||
```bash
|
||
cp config.example.yaml config.yaml
|
||
go run main.go all
|
||
```
|
||
|
||
分进程启动:
|
||
|
||
```bash
|
||
go run main.go api # 仅 HTTP API
|
||
go run main.go worker # 仅 Asynq Worker
|
||
go run main.go scheduler # 仅定时任务调度
|
||
```
|
||
|
||
编译二进制:
|
||
|
||
```bash
|
||
make build-backend
|
||
# 产物:bin/openflare-server
|
||
```
|
||
|
||
测试:
|
||
|
||
```bash
|
||
GOCACHE=/tmp/openflare-go-cache go test ./...
|
||
```
|
||
|
||
质量门禁:
|
||
|
||
```bash
|
||
make code-check
|
||
```
|
||
|
||
自动格式化后端 Go 源码(整理导入)与前端源码:
|
||
|
||
```bash
|
||
make format
|
||
```
|
||
|
||
该命令使用 `goimports` 整理后端 Go 源码导入,并使用项目固定版本的 Prettier 格式化 `frontend/` 源码;构建产物、依赖、公开静态资源和锁文件会被忽略。
|
||
|
||
## Frontend
|
||
|
||
开发:
|
||
|
||
```bash
|
||
cd frontend
|
||
pnpm install
|
||
pnpm dev
|
||
```
|
||
|
||
构建嵌入产物(供 Go Server 托管):
|
||
|
||
```bash
|
||
cd frontend
|
||
pnpm build:embed
|
||
# 或仓库根目录:make build-embedded
|
||
```
|
||
|
||
检查:
|
||
|
||
```bash
|
||
cd frontend
|
||
pnpm lint
|
||
pnpm tsc --noEmit --jsx preserve
|
||
pnpm check:i18n
|
||
```
|
||
|
||
## Agent
|
||
|
||
源码运行:
|
||
|
||
```bash
|
||
go run ./cmd/agent -config /path/to/agent.json
|
||
```
|
||
|
||
编译:
|
||
|
||
```bash
|
||
make build-agent
|
||
# 或:go build -o bin/openflare-agent ./cmd/agent
|
||
```
|
||
|
||
测试:
|
||
|
||
```bash
|
||
GOCACHE=/tmp/openflare-go-cache go test ./internal/apps/agent/...
|
||
```
|
||
|
||
## Relay(中继端)
|
||
|
||
源码运行:
|
||
|
||
```bash
|
||
go run ./cmd/relay -config /path/to/relay.json
|
||
```
|
||
|
||
编译:
|
||
|
||
```bash
|
||
make build-relay
|
||
# 或:go build -o bin/openflare-relay ./cmd/relay
|
||
```
|
||
|
||
## OpenFlared(Tunnel 客户端)
|
||
|
||
源码运行:
|
||
|
||
```bash
|
||
go run ./cmd/flared -config /path/to/flared.json
|
||
```
|
||
|
||
编译:
|
||
|
||
```bash
|
||
make build-flared
|
||
# 或:go build -o bin/flared ./cmd/flared
|
||
```
|
||
|
||
## 安装 Agent
|
||
|
||
```bash
|
||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/install-agent.sh | bash -s -- \
|
||
--server-url http://your-server:3000 \
|
||
--agent-token YOUR_AGENT_TOKEN
|
||
```
|
||
|
||
## 卸载 Agent
|
||
|
||
```bash
|
||
curl -fsSL https://raw.githubusercontent.com/Rain-kl/OpenFlare/main/scripts/uninstall-agent.sh | bash
|
||
```
|
||
|
||
## Swagger
|
||
|
||
重新生成 Swagger 文档:
|
||
|
||
```bash
|
||
make swagger
|
||
```
|
||
|
||
访问:`http://localhost:3000/api/swagger/index.html`(默认 `api_prefix` 为 `/api`,仅非生产环境挂载)
|
||
|
||
## Docs
|
||
|
||
本地预览:
|
||
|
||
```bash
|
||
cd docs
|
||
pnpm dev
|
||
```
|
||
|
||
构建:
|
||
|
||
```bash
|
||
cd docs
|
||
pnpm build
|
||
```
|