feat: add CLI commands documentation and service management features

- Updated the VitePress configuration to include links to CLI commands in both English and Chinese.
- Enhanced the AstrBot deployment documentation with instructions for installing it as a system service.
- Created comprehensive CLI commands documentation covering initialization, service management, configuration, and plugin management.
- Added tests for CLI command aliases and service functionalities to ensure proper command registration and behavior.
- Implemented service log management features, including enabling application logging and controlling log visibility.
This commit is contained in:
Soulter
2026-05-21 23:44:28 +08:00
parent 0711172fa7
commit 97f0fd3de3
12 changed files with 2555 additions and 10 deletions

View File

@@ -22,3 +22,68 @@ uv tool install astrbot --python 3.12
astrbot init # 只需要在第一次部署时执行,后续启动不需要执行
astrbot run
```
## 安装为系统服务
初始化完成后,可以安装用户级服务,让 AstrBot 随用户会话自动启动:
```bash
astrbot service install --now
```
该命令会自动使用当前 `PATH` 中的 `astrbot` 可执行文件(通常由 `uv tool install` 生成),并将当前目录作为 AstrBot 工作目录。不同系统会使用对应的用户级服务机制:
- Linux`systemd --user`
- macOS`LaunchAgent`
- Windows任务计划程序
如果需要指定 AstrBot 工作目录或可执行文件路径,可以使用:
```bash
astrbot service install --workdir /path/to/astrbot-root --executable /path/to/astrbot --now
```
查看服务状态和 WebUI 健康状态:
```bash
astrbot service status
```
状态输出会包含服务管理器状态、AstrBot 工作目录、Dashboard 端口、WebUI URL、WebUI 是否可访问,以及整体健康状态。
也可以使用以下命令管理服务生命周期:
```bash
astrbot service start
astrbot service stop
astrbot service restart
astrbot service uninstall
```
查看服务日志:
```bash
astrbot service logs
astrbot service logs -f
```
macOS 和 Windows 下默认只显示标准输出日志;如需同时查看 stderr
```bash
astrbot service logs --include-stderr
```
如果需要查看 AstrBot 应用日志文件 `data/logs/astrbot.log`,先启用应用日志文件并重启服务:
```bash
astrbot service logs enable
astrbot service restart
astrbot service logs --source app
```
查看或关闭应用日志文件:
```bash
astrbot service logs status
astrbot service logs disable
```