Documentation
¶
Index ¶
- func BaseDir() string
- func CheckAndClean(name string) (bool, error)
- func Delete(name string) error
- func EnsureLogDir() error
- func EnsureTelemetryServerDir(stackName, serverName string) error
- func FindOrphan(port int) (int, bool, error)
- func IsRunning(state *DaemonState) bool
- func KillDaemon(state *DaemonState) error
- func LimitsDir() string
- func LimitsLedgerPath(name string) string
- func LockPath(name string) string
- func LogDir() string
- func LogPath(name string) string
- func PinsDir() string
- func PinsPath(name string) string
- func Save(state *DaemonState) error
- func StacksDir() string
- func StateDir() string
- func StatePath(name string) string
- func TelemetryDir() string
- func TelemetryServerDir(stackName, serverName string) string
- func TelemetryServerPath(stackName, serverName, signal string) string
- func VaultDir() string
- func VerifyPID(pid int) bool
- func WithLock(name string, timeout time.Duration, fn func() error) error
- type DaemonState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckAndClean ¶
CheckAndClean checks if a state file exists and if the process is running. If the process is dead, it removes the state file and returns true (cleaned). If the process is running, it returns false (not cleaned). If no state file exists, it returns false.
func EnsureLogDir ¶
func EnsureLogDir() error
EnsureLogDir creates the log directory if it doesn't exist.
func EnsureTelemetryServerDir ¶
EnsureTelemetryServerDir creates the per-server telemetry directory with mode 0700, matching the vault/state convention. Any new directories on the path inherit the same restrictive permissions because lumberjack will not chmod them on its own.
func FindOrphan ¶
FindOrphan looks for an orphan gridctl daemon listening on port — a process that owns the port but has no managed state file (because e.g. an earlier shutdown deleted state mid-way, or the daemon was started in a mode that doesn't write state, like 'serve --foreground').
Returns (pid, true, nil) only when all three signals agree:
- The /health endpoint on port responds 200.
- Exactly one process (after excluding our own PID) holds the TCP listen socket for that port.
- That process's executable basename is "gridctl".
Any ambiguity — health probe fails, no listener, multiple listeners after self-exclusion, or executable name mismatch — returns ok=false so the caller falls through to the legacy behavior rather than acting on guesswork.
func IsRunning ¶
func IsRunning(state *DaemonState) bool
IsRunning checks if the daemon process is still running.
func KillDaemon ¶
func KillDaemon(state *DaemonState) error
KillDaemon sends SIGTERM to the daemon process, waits up to 5 seconds for graceful shutdown, then sends SIGKILL if the process is still running.
func LimitsDir ¶
func LimitsDir() string
LimitsDir returns the directory for budget spend ledgers (~/.gridctl/limits/).
func LimitsLedgerPath ¶
LimitsLedgerPath returns the path to the budget spend ledger for a stack (~/.gridctl/limits/{name}.json).
func PinsDir ¶
func PinsDir() string
PinsDir returns the directory for schema pin files (~/.gridctl/pins/).
func PinsPath ¶
PinsPath returns the path to the pin file for a stack (~/.gridctl/pins/{name}.json).
func StacksDir ¶
func StacksDir() string
StacksDir returns the directory for saved stack files (~/.gridctl/stacks/).
func StateDir ¶
func StateDir() string
StateDir returns the directory for state files (~/.gridctl/state/).
func TelemetryDir ¶
func TelemetryDir() string
TelemetryDir returns the root directory for opt-in telemetry persistence (~/.gridctl/telemetry/). Subtree layout: <stack>/<server>/{logs,metrics,traces}.jsonl.
func TelemetryServerDir ¶
TelemetryServerDir returns the per-server directory under TelemetryDir for the given stack and server.
func TelemetryServerPath ¶
TelemetryServerPath returns the path to a single signal file for a server. signal must be "logs", "metrics", or "traces"; any string is accepted but only those three are produced by the daemon.
func VaultDir ¶
func VaultDir() string
VaultDir returns the directory for vault storage (~/.gridctl/vault/).