2025-04-14 19:17:53 +08:00

34 lines
1.8 KiB
Markdown
Raw Permalink 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.

# Paw GUi
Paw 的系统服务及其安装/卸载器
此处 `install.rs``uninstall.rs` 中使用的 `Command` 都是同步版本,而其他属于服务部分的`Command`都是异步版本。
同理,`install.rs``uninstall.rs` 中使用的日志均为直接 `println!`,而服务部分依赖于 `tracing` 输出到标准输出流从而被操作系统的服务日志系统记录Windows下输出到文件。因此三个系统的服务日志查看方式如下
- Linux: `sudo journalctl -u paw-system-service` 其中具体名称由 `common` 中的 `SERVICE_NAME` 决定
- macOS: `/var/log/com.paw.service.log` 其中具体名称由 `common` 中的 `SERVICE_MACOS_NAME` 决定
- Windows: 文件在 `软件所在目录/logs/`
## 项目结构
- src/
- main.rs 系统服务的入口文件
- api.rs 系统服务的API接口
- installer/ 系统服务安装/卸载器
- install.rs 系统服务安装器
- uninstall.rs 系统服务卸载器
- template/ 系统服务模板
- helper.plist macOS 的系统服务
- systemctl.txt Linux 的系统服务
## 第三方库依赖
- [serde](https://serde.rs/) & serde_json: 序列化/反序列化框架
- [anyhow](https://github.com/dtolnay/anyhow) 简化错误处理
- [tokio](https://tokio.rs/tokio/tutorial) 异步运行时,也包含了很多异步实用工具
- [axum](https://crates.io/crates/axum) HTTP服务器
- [windows-service](https://crates.io/crates/windows-service) Windows 系统服务控制框架,用于安装、卸载、修改系统服务
- [tracing](https://crates.io/crates/tracing) [tracing-subscriber](https://crates.io/crates/tracing-subscriber) 记录系统服务的日志
- [tracing-appender](https://crates.io/crates/tracing-appender/) 将日志输出到文件,仅 Windows 使用