Files
2026-08-17 10:10:14 +08:00

36 lines
1.0 KiB
Go
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.
// Package systemd 定义原生执行器所依赖的精确 systemd 边界。
//
// 该包声明 systemd 操作所需的最小抽象,具体实现见 systemctl.go
// 它直接调用 systemctl 可执行文件,绝不经过 shell。
package systemd
import (
"context"
"errors"
)
// ErrUnitNotFound 表示未找到指定的 systemd 单元。
var ErrUnitNotFound = errors.New("systemd unit not found")
// Unit 执行幂等启停检查所需的 systemd 状态。
type Unit struct {
// Name 表示单元名称。
Name string
// LoadState 表示单元的加载状态。
LoadState string
// ActiveState 表示单元的活动状态。
ActiveState string
// SubState 表示单元的子状态。
SubState string
}
// Manager 在不调用 shell 的前提下直接执行 systemd 操作。
type Manager interface {
// Inspect 检查指定单元并返回其状态。
Inspect(context.Context, string) (Unit, error)
// Start 启动指定单元。
Start(context.Context, string) error
// Stop 停止指定单元。
Stop(context.Context, string) error
}