Documentation
¶
Index ¶
- Variables
- func ClaimDaemon() (func(), error)
- func ClaimReload() (func(), error)
- func IsDaemonRunning() bool
- func NewRequestID() string
- func ProcessExecutableName(pid int) (string, error)
- func ProcessRecordIsLive(record PIDRecord) bool
- func ReadJSON(path string, value any) error
- func SignalDaemon(sig syscall.Signal) error
- func SignalProcessRecord(record PIDRecord, sig syscall.Signal) error
- func StopDaemon(timeout time.Duration) (bool, error)
- func TerminateProcessRecord(record PIDRecord, sig syscall.Signal, timeout time.Duration) error
- func WaitProcessRecord(record PIDRecord, timeout time.Duration) error
- func WaitResponse(path, id string, timeout time.Duration) error
- func WriteJSONAtomic(path string, value any, mode os.FileMode) error
- type PIDRecord
- type ReloadRequest
- type Response
Constants ¶
This section is empty.
Variables ¶
var ( RunDir = "/run/nic" PIDPath = RunDir + "/nic.pid" AppliedConfigPath = RunDir + "/applied-config.json" PendingConfigPath = RunDir + "/pending-config.json" BaseStatePath = RunDir + "/base-state.json" ReloadRequestPath = RunDir + "/reload-request.json" ReloadResponsePath = RunDir + "/reload-response.json" ReloadLockPath = RunDir + "/reload.lock" RevertResponsePath = RunDir + "/revert-response.json" )
var ( ErrNotRunning = errors.New("nic daemon is not running") ErrReloadInProgress = errors.New("nic reload is already in progress") )
Functions ¶
func ClaimDaemon ¶
func ClaimDaemon() (func(), error)
ClaimDaemon atomically claims the daemon PID file. Stale records are removed only after the recorded process start time no longer matches.
func ClaimReload ¶
func ClaimReload() (func(), error)
ClaimReload serializes CLI reload requests. A file lock is automatically released if the requesting process exits, so it cannot leave a stale lock that blocks future network changes.
func IsDaemonRunning ¶
func IsDaemonRunning() bool
func NewRequestID ¶
func NewRequestID() string
func ProcessExecutableName ¶
func ProcessRecordIsLive ¶
func SignalDaemon ¶
func TerminateProcessRecord ¶
TerminateProcessRecord signals a tracked process and waits until it has actually exited. Callers must keep their PID/configuration records when this returns an error so a live process cannot be replaced by a second instance.
func WaitProcessRecord ¶
WaitProcessRecord waits for the exact recorded process to exit. The start time check prevents a recycled PID from being mistaken for the process that nic originally launched.
Types ¶
type PIDRecord ¶
func DaemonRecord ¶
DaemonRecord returns the identity of the currently running daemon. The process start time makes the identity safe even if the kernel later reuses its PID.