Documentation
¶
Overview ¶
Package state manages persistent devrig project state in .devrig/state.json.
Index ¶
- func Remove(stateDir string) error
- func StateDir(configPath string) string
- func UpdateServiceExit(stateDir, service string, code int)
- func UpdateServicePhase(stateDir, service, phase string)
- func UpdateServiceProc(stateDir, service string, pid uint32, startTimeMs int64)
- type AddonState
- type ClusterDeployState
- type ClusterState
- type ComposeServiceState
- type DashboardState
- type DockerState
- type ProjectState
- type ServiceState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UpdateServiceExit ¶
UpdateServiceExit writes the exit code for a service.
func UpdateServicePhase ¶
func UpdateServicePhase(stateDir, service, phase string)
UpdateServicePhase writes the phase field for a service.
func UpdateServiceProc ¶ added in v0.34.3
UpdateServiceProc writes the PID and process start time for a service into state.json using an exclusive file lock.
Types ¶
type AddonState ¶
type ClusterDeployState ¶
type ClusterState ¶
type ClusterState struct {
ClusterName string `json:"cluster_name"`
KubeconfigPath string `json:"kubeconfig_path"`
RegistryName *string `json:"registry_name,omitempty"`
RegistryPort *uint16 `json:"registry_port,omitempty"`
DeployedServices map[string]ClusterDeployState `json:"deployed_services"`
InstalledAddons map[string]AddonState `json:"installed_addons"`
}
type ComposeServiceState ¶
type DashboardState ¶
type DockerState ¶
type DockerState struct {
ContainerID string `json:"container_id"`
ContainerName string `json:"container_name"`
Port *uint16 `json:"port,omitempty"`
PortAuto bool `json:"port_auto"`
Protocol *string `json:"protocol,omitempty"`
NamedPorts map[string]uint16 `json:"named_ports"`
InitCompleted bool `json:"init_completed"`
InitCompletedAt *time.Time `json:"init_completed_at,omitempty"`
}
type ProjectState ¶
type ProjectState struct {
Slug string `json:"slug"`
ConfigPath string `json:"config_path"`
StartedAt time.Time `json:"started_at"`
Services map[string]ServiceState `json:"services"`
Docker map[string]DockerState `json:"docker"`
ComposeServices map[string]ComposeServiceState `json:"compose_services"`
NetworkName *string `json:"network_name,omitempty"`
Cluster *ClusterState `json:"cluster,omitempty"`
Dashboard *DashboardState `json:"dashboard,omitempty"`
// PID of the main devrig process (written so `devrig stop` can signal it).
PID int `json:"pid,omitempty"`
// PIDStartTimeMs is the devrig process's creation time (ms since epoch),
// stored so `devrig stop` can confirm the PID hasn't been reused before
// signalling it.
PIDStartTimeMs int64 `json:"pid_start_time_ms,omitempty"`
}
ProjectState is serialised to .devrig/state.json.
func Load ¶
func Load(stateDir string) *ProjectState
Load reads state.json from stateDir. Returns nil if it doesn't exist or can't be parsed.
func (*ProjectState) Save ¶
func (s *ProjectState) Save(stateDir string) error
Save writes state to state.json atomically (tmp → rename).
type ServiceState ¶
type ServiceState struct {
PID uint32 `json:"pid"`
// StartTimeMs is the service process's creation time (ms since epoch),
// recorded alongside PID so a later run can reuse-proof identify and reap an
// orphan left by a crashed devrig.
StartTimeMs int64 `json:"start_time_ms,omitempty"`
Port *uint16 `json:"port,omitempty"`
PortAuto bool `json:"port_auto"`
Protocol *string `json:"protocol,omitempty"`
Phase *string `json:"phase,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.