docs(agent): 统一中文注释并补充部署文档

将代码与测试注释改为中文以符合仓库规范;新增中文部署指南、
示例配置,并完善构建脚本对 VERSION 注入的说明。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
codex
2026-05-19 02:30:49 +00:00
parent 89d5e27874
commit 877e4cf41d
28 changed files with 608 additions and 226 deletions

View File

@@ -9,15 +9,15 @@ import (
"mfd-monitor-agent/internal/config"
)
// windowsManager manages the agent through the Windows Service Control Manager.
// windowsManager 通过 Windows 服务控制管理器(SCM)管理 agent。
type windowsManager struct{}
// newManager returns the Windows service manager.
// newManager 返回 Windows 服务管理器。
func newManager() Manager {
return windowsManager{}
}
// Install registers the agent executable as an auto-start Windows Service.
// Install 将 agent 可执行文件注册为自动启动的 Windows 服务。
func (windowsManager) Install(executable string, cfg config.Config, opts InstallOptions) error {
args := []string{`"` + executable + `"`, "run"}
if opts.ConfigPath != "" {
@@ -26,18 +26,18 @@ func (windowsManager) Install(executable string, cfg config.Config, opts Install
return exec.Command("sc.exe", "create", cfg.Service.Name, "binPath=", strings.Join(args, " "), "DisplayName=", cfg.Service.DisplayName, "start=", "auto").Run()
}
// Uninstall stops and removes the configured Windows Service.
// Uninstall 停止并删除已配置的 Windows 服务。
func (windowsManager) Uninstall(cfg config.Config) error {
_ = exec.Command("sc.exe", "stop", cfg.Service.Name).Run()
return exec.Command("sc.exe", "delete", cfg.Service.Name).Run()
}
// Start asks the Windows Service Control Manager to start the service.
// Start 请求 SCM 启动服务。
func (windowsManager) Start(cfg config.Config) error {
return exec.Command("sc.exe", "start", cfg.Service.Name).Run()
}
// Stop asks the Windows Service Control Manager to stop the service.
// Stop 请求 SCM 停止服务。
func (windowsManager) Stop(cfg config.Config) error {
return exec.Command("sc.exe", "stop", cfg.Service.Name).Run()
}