lolly/internal/app/AGENTS.md
xfy 179aacac04 docs: 添加模块上下文文档 (AGENTS.md)
为各模块添加上下文文档,帮助 AI 助手理解代码结构:
- AGENTS.md: 项目根目录上下文
- docs/AGENTS.md: 文档目录说明
- internal/AGENTS.md: 内部包结构概览
- 各子模块 AGENTS.md: 模块特定上下文和约定

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 16:25:51 +08:00

40 lines
1.3 KiB
Markdown
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.

<!-- Parent: ../AGENTS.md -->
<!-- Generated: 2026-04-02 | Updated: 2026-04-02 -->
# app
## Purpose
应用程序入口包,提供启动逻辑、信号处理、版本信息显示和配置生成功能。
## Key Files
| File | Description |
|------|-------------|
| `app.go` | 核心逻辑Run 入口、startServer、printVersion、generateConfig |
| `app_test.go` | 单元测试:版本显示、配置生成、服务器启动测试 |
## For AI Agents
### Working In This Directory
- 版本信息变量通过 `-ldflags` 在编译时注入,不要硬编码修改
- `Run()` 是程序入口函数,返回退出码
- 信号处理SIGTERM/SIGINT 快速停止SIGQUIT 优雅停止(等待 30s
- `generateConfig()` 生成默认 YAML 配置,调用 `config.DefaultConfig()`
### Testing Requirements
- 测试文件 `app_test.go` 包含启动逻辑测试
- 运行测试:`go test ./internal/app/...`
- 测试覆盖率目标 >80%
### Common Patterns
- 使用 `os.Signal``signal.Notify` 处理系统信号
- 服务器启动在 goroutine 中执行,通过 channel 等待错误或信号
- `shutdownTimeout` 定义优雅停止超时时间
## Dependencies
### Internal
- `../config/` - 配置加载和验证
- `../server/` - HTTP 服务器创建和启动
<!-- MANUAL: -->