docs(agent): 统一中文注释并补充部署文档
将代码与测试注释改为中文以符合仓库规范;新增中文部署指南、 示例配置,并完善构建脚本对 VERSION 注入的说明。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,15 +13,15 @@ import (
|
||||
|
||||
var currentUID = os.Geteuid
|
||||
|
||||
// linuxManager manages a systemd service for the agent.
|
||||
// linuxManager 通过 systemd 管理 agent 服务。
|
||||
type linuxManager struct{}
|
||||
|
||||
// newManager returns the Linux systemd-backed service manager.
|
||||
// newManager 返回基于 Linux systemd 的服务管理器。
|
||||
func newManager() Manager {
|
||||
return linuxManager{}
|
||||
}
|
||||
|
||||
// Install writes a systemd unit, reloads systemd, and enables the configured service.
|
||||
// Install 写入 systemd unit、重载 systemd 并 enable 配置的服务。
|
||||
func (linuxManager) Install(executable string, cfg config.Config, opts InstallOptions) error {
|
||||
if currentUID() != 0 {
|
||||
return fmt.Errorf("install requires root")
|
||||
@@ -40,7 +40,7 @@ func (linuxManager) Install(executable string, cfg config.Config, opts InstallOp
|
||||
return nil
|
||||
}
|
||||
|
||||
// renderSystemdUnit builds the Linux systemd unit used by Install.
|
||||
// renderSystemdUnit 生成 Install 使用的 Linux systemd unit 内容。
|
||||
func renderSystemdUnit(executable string, configPath string, cfg config.Config) string {
|
||||
args := []string{executable, "run"}
|
||||
if configPath != "" {
|
||||
@@ -62,7 +62,7 @@ WantedBy=multi-user.target
|
||||
`, cfg.Service.Description, strings.Join(args, " "))
|
||||
}
|
||||
|
||||
// Uninstall disables the service, removes its unit file, and reloads systemd.
|
||||
// Uninstall 禁用服务、删除 unit 文件并重载 systemd。
|
||||
func (linuxManager) Uninstall(cfg config.Config) error {
|
||||
_ = exec.Command("systemctl", "disable", "--now", cfg.Service.Name).Run()
|
||||
if err := os.Remove("/etc/systemd/system/" + cfg.Service.Name + ".service"); err != nil && !os.IsNotExist(err) {
|
||||
@@ -71,12 +71,12 @@ func (linuxManager) Uninstall(cfg config.Config) error {
|
||||
return exec.Command("systemctl", "daemon-reload").Run()
|
||||
}
|
||||
|
||||
// Start asks systemd to start the configured service.
|
||||
// Start 请求 systemd 启动配置的服务。
|
||||
func (linuxManager) Start(cfg config.Config) error {
|
||||
return exec.Command("systemctl", "start", cfg.Service.Name).Run()
|
||||
}
|
||||
|
||||
// Stop asks systemd to stop the configured service.
|
||||
// Stop 请求 systemd 停止配置的服务。
|
||||
func (linuxManager) Stop(cfg config.Config) error {
|
||||
return exec.Command("systemctl", "stop", cfg.Service.Name).Run()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user