state

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateDirName  = ".devctl"
	StateFilename = "state.json"
	LogsDirName   = "logs"
)

Variables

This section is empty.

Functions

func FilterEnvForDisplay

func FilterEnvForDisplay(env map[string]string, maxVars int) map[string]string

FilterEnvForDisplay returns a subset of environment variables suitable for display. It removes common noise variables and limits the total count.

func LogsDir

func LogsDir(repoRoot string) string

func ProcessAlive

func ProcessAlive(pid int) bool

func Remove

func Remove(repoRoot string) error

func SanitizeEnv

func SanitizeEnv(env map[string]string) map[string]string

SanitizeEnv returns a copy of the environment map with sensitive values redacted. Keys containing patterns like PASSWORD, SECRET, TOKEN, KEY, CREDENTIAL, etc. will have their values replaced with "[REDACTED]".

func Save

func Save(repoRoot string, s *State) error

func StatePath

func StatePath(repoRoot string) string

func TailLines

func TailLines(path string, tailLines int, maxBytes int64) ([]string, error)

func WriteExitInfo

func WriteExitInfo(path string, info ExitInfo) error

Types

type ExitInfo

type ExitInfo struct {
	Service   string    `json:"service"`
	PID       int       `json:"pid"`
	StartedAt time.Time `json:"started_at"`
	ExitedAt  time.Time `json:"exited_at"`

	ExitCode *int   `json:"exit_code,omitempty"`
	Signal   string `json:"signal,omitempty"`
	Error    string `json:"error,omitempty"`

	StderrTail []string `json:"stderr_tail,omitempty"`
	StdoutTail []string `json:"stdout_tail,omitempty"`
}

func ReadExitInfo

func ReadExitInfo(path string) (*ExitInfo, error)

type ServiceRecord

type ServiceRecord struct {
	Name      string            `json:"name"`
	PID       int               `json:"pid"`
	Command   []string          `json:"command"`
	Cwd       string            `json:"cwd"`
	Env       map[string]string `json:"env,omitempty"`
	StdoutLog string            `json:"stdout_log"`
	StderrLog string            `json:"stderr_log"`
	ExitInfo  string            `json:"exit_info,omitempty"`
	StartedAt time.Time         `json:"started_at,omitempty"` // When the process was started

	// Health check configuration (if any)
	HealthType    string `json:"health_type,omitempty"`    // "tcp"|"http"
	HealthAddress string `json:"health_address,omitempty"` // For TCP checks
	HealthURL     string `json:"health_url,omitempty"`     // For HTTP checks
}

type State

type State struct {
	RepoRoot  string          `json:"repo_root"`
	CreatedAt time.Time       `json:"created_at"`
	Services  []ServiceRecord `json:"services"`
}

func Load

func Load(repoRoot string) (*State, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL