命令与脚本
你会学到: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-server
# 产物:bin/openflare-server测试:
bash
GOCACHE=/tmp/openflare-go-cache go test ./...质量门禁:
bash
make code-checkFrontend
开发:
bash
cd frontend
pnpm install
pnpm dev构建嵌入产物(供 Go Server 托管):
bash
cd frontend
pnpm build:embed
# 或仓库根目录:make build-embedded检查:
bash
cd frontend
pnpm lint
pnpm typecheckAgent
源码运行:
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/relayOpenFlared(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 | bashSwagger
重新生成 Swagger 文档:
bash
make swagger访问:http://localhost:3000/swagger/index.html
Docs
本地预览:
bash
cd docs
pnpm dev构建:
bash
cd docs
pnpm build:embed