Documentation
¶
Index ¶
- Variables
- type APIConfig
- type Config
- type Controller
- func (this *Controller) AllowedFilePaths() map[string]bool
- func (this *Controller) BuildTarget(name string) error
- func (this *Controller) DisableTarget(name string) error
- func (this *Controller) EnableTarget(name string) error
- func (this *Controller) FavicoStatus() favico.Status
- func (this *Controller) KillTargets()
- func (this *Controller) Overview() Overview
- func (this *Controller) RestartTarget(name string) error
- func (this *Controller) Routes() chi.Router
- func (this *Controller) StartExec(name string) error
- func (this *Controller) StartTarget(name string) error
- func (this *Controller) StartTargets()
- func (this *Controller) StartTargetsFiltered(names []string)
- func (this *Controller) Status() []TargetStatus
- func (this *Controller) StopExec(name string) error
- func (this *Controller) StopTarget(name string) error
- func (this *Controller) StopTargets()
- func (this *Controller) TargetStatus(name string) (*TargetStatus, error)
- func (this *Controller) TestTarget(name string) error
- type FaviconConfig
- type HeartbeatSummary
- type Link
- type LogsConfig
- type Overview
- type PhaseStatus
- type TargetConfig
- type TargetState
- type TargetStatus
Constants ¶
This section is empty.
Variables ¶
var DefaultConfigYAML string
DefaultConfigYAML is the commented starter YAML for `runctl init`.
Functions ¶
This section is empty.
Types ¶
type APIConfig ¶
type APIConfig struct {
Port int `yaml:"port"`
}
APIConfig controls the HTTP API server.
type Config ¶
type Config struct {
Title string `yaml:"title,omitempty"`
Description string `yaml:"description,omitempty"`
Favicon FaviconConfig `yaml:"favicon,omitempty"`
Vars map[string]string `yaml:"vars,omitempty"`
API APIConfig `yaml:"api"`
LogsDir string `yaml:"logs_dir,omitempty"` // directory for auto-generated log files
LogsRotateOnStart *bool `yaml:"logs_rotate_on_start,omitempty"` // rename existing log files to *.<timestamp>.log on startup (default: true)
Targets map[string]TargetConfig `yaml:"targets"`
// ResolvedVars holds all resolved template variables (vars section + env).
// Populated by LoadConfig, not from YAML.
ResolvedVars map[string]string `yaml:"-"`
}
Config is the top-level runctl.yaml configuration.
func LoadConfig ¶
LoadConfig reads and parses a runctl.yaml file. Template variables from the vars: section are resolved using Go templates, then set in the process environment (if not already present) so child configs can access them.
func (Config) RotatesLogsOnStart ¶ added in v0.1.15
RotatesLogsOnStart returns whether existing log files should be renamed to a timestamped backup when runctl starts (default: true).
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller manages multiple targets and exposes an HTTP API.
func New ¶
func New(cfg Config, baseDir string, verbose bool) (*Controller, error)
New creates a Controller from the given config. baseDir is the directory containing runctl.yaml (used to resolve relative target dirs).
func (*Controller) AllowedFilePaths ¶ added in v0.1.1
func (this *Controller) AllowedFilePaths() map[string]bool
AllowedFilePaths returns the set of absolute file paths from link configs. Used to restrict which files the /api/file endpoint can serve.
func (*Controller) BuildTarget ¶
func (this *Controller) BuildTarget(name string) error
BuildTarget triggers a rebuild + restart for a target.
func (*Controller) DisableTarget ¶
func (this *Controller) DisableTarget(name string) error
DisableTarget stops a target and disables it.
func (*Controller) EnableTarget ¶
func (this *Controller) EnableTarget(name string) error
EnableTarget enables a target and starts it.
func (*Controller) FavicoStatus ¶ added in v0.1.24
func (this *Controller) FavicoStatus() favico.Status
FavicoStatus returns a compact health rollup for the browser favicon.
func (*Controller) KillTargets ¶
func (this *Controller) KillTargets()
KillTargets immediately kills all target processes (SIGKILL).
func (*Controller) Overview ¶ added in v0.1.15
func (this *Controller) Overview() Overview
Overview returns project metadata and current target status.
func (*Controller) RestartTarget ¶
func (this *Controller) RestartTarget(name string) error
RestartTarget stops and re-starts a target.
func (*Controller) Routes ¶
func (this *Controller) Routes() chi.Router
Routes returns a chi.Router with all API routes mounted. Caller mounts it at any prefix: mainRouter.Mount("/api", ctrl.Routes())
func (*Controller) StartExec ¶
func (this *Controller) StartExec(name string) error
StartExec starts just the managed process (no rebuild).
func (*Controller) StartTarget ¶
func (this *Controller) StartTarget(name string) error
StartTarget starts a target by name.
func (*Controller) StartTargets ¶
func (this *Controller) StartTargets()
StartTargets launches all enabled targets.
func (*Controller) StartTargetsFiltered ¶ added in v0.1.3
func (this *Controller) StartTargetsFiltered(names []string)
StartTargetsFiltered launches only the named targets. If names is empty, it starts all enabled targets (same as StartTargets).
func (*Controller) Status ¶
func (this *Controller) Status() []TargetStatus
Status returns the status of all targets.
func (*Controller) StopExec ¶
func (this *Controller) StopExec(name string) error
StopExec stops just the managed process (keep watcher running).
func (*Controller) StopTarget ¶
func (this *Controller) StopTarget(name string) error
StopTarget stops a target by name.
func (*Controller) StopTargets ¶
func (this *Controller) StopTargets()
StopTargets gracefully stops all targets (SIGTERM → 5s → SIGKILL).
func (*Controller) TargetStatus ¶
func (this *Controller) TargetStatus(name string) (*TargetStatus, error)
TargetStatus returns the status of a single target.
func (*Controller) TestTarget ¶ added in v0.1.15
func (this *Controller) TestTarget(name string) error
TestTarget triggers tests for a target.
type FaviconConfig ¶ added in v0.1.24
type FaviconConfig struct {
Name string `yaml:"name,omitempty"`
}
FaviconConfig controls the browser tab icon served at /favicon.ico.
type HeartbeatSummary ¶ added in v0.1.15
HeartbeatSummary is the aggregated console heartbeat state for selected targets.
func SummarizeHeartbeat ¶ added in v0.1.15
func SummarizeHeartbeat(statuses []TargetStatus, selected map[string]bool) HeartbeatSummary
SummarizeHeartbeat returns the pessimistic build/run/test aggregate for console output. If selected is empty, all enabled targets are included.
func (HeartbeatSummary) FailureTuple ¶ added in v0.1.15
func (s HeartbeatSummary) FailureTuple() string
func (HeartbeatSummary) HasFailures ¶ added in v0.1.15
func (s HeartbeatSummary) HasFailures() bool
type Link ¶
type Link struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
URL string `yaml:"url,omitempty" json:"url,omitempty"`
File string `yaml:"file,omitempty" json:"file,omitempty"`
ResolvedURL string `yaml:"-" json:"resolved_url,omitempty"`
}
Link is a named URL or file path associated with a target.
type LogsConfig ¶
type LogsConfig struct {
Build string `json:"build,omitempty"` // build stage log file
Test string `json:"test,omitempty"` // test stage log file
Run string `json:"run,omitempty"` // run stage log file
}
LogsConfig holds resolved log file paths for a target. Populated internally from Config.LogsDir. Files are separated by stage: build (compile/exec steps) and run (managed process).
type Overview ¶ added in v0.1.15
type Overview struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Targets []TargetStatus `json:"targets"`
}
Overview is the dashboard/API payload for project-level metadata and targets.
type PhaseStatus ¶ added in v0.1.15
type PhaseStatus struct {
Time *time.Time `json:"time,omitempty"`
Duration *float64 `json:"duration_secs,omitempty"`
Result string `json:"result,omitempty"`
Error string `json:"error,omitempty"`
Count int `json:"count"`
}
PhaseStatus is the structured status for a build/test phase.
type TargetConfig ¶
type TargetConfig struct {
Config string `yaml:"config"` // path to config file (relative to runctl.yaml dir)
Enabled *bool `yaml:"enabled,omitempty"`
Links []Link `yaml:"links,omitempty"`
Vars map[string]string `yaml:"vars,omitempty"` // per-target template vars (override global vars)
// Logs is populated internally from Config.LogsDir — not user-configurable.
Logs *LogsConfig `yaml:"-"`
}
TargetConfig describes a single managed target.
func (TargetConfig) IsEnabled ¶
func (this TargetConfig) IsEnabled() bool
IsEnabled returns whether the target should start on launch (default: true).
type TargetState ¶
type TargetState string
TargetState represents the current state of a target.
const ( StateIdle TargetState = "idle" StateStarting TargetState = "starting" StateRunning TargetState = "running" StateStopped TargetState = "stopped" StateError TargetState = "error" StateExited TargetState = "exited" )
type TargetStatus ¶
type TargetStatus struct {
Name string `json:"name"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
HasBuild bool `json:"has_build"`
HasTest bool `json:"has_test"`
HasRun bool `json:"has_run"`
State TargetState `json:"state"`
CurrentStage string `json:"current_stage,omitempty"`
Enabled bool `json:"enabled"`
PID int `json:"pid,omitempty"`
Build PhaseStatus `json:"build"`
Test PhaseStatus `json:"test"`
LastBuildTime *time.Time `json:"last_build_time,omitempty"`
LastBuildDuration *float64 `json:"last_build_duration_secs,omitempty"`
LastBuildResult string `json:"last_build_result,omitempty"`
LastBuildError string `json:"last_build_error,omitempty"`
LastTestTime *time.Time `json:"last_test_time,omitempty"`
LastTestDuration *float64 `json:"last_test_duration_secs,omitempty"`
LastTestResult string `json:"last_test_result,omitempty"`
LastTestError string `json:"last_test_error,omitempty"`
LastExecTime *time.Time `json:"last_exec_time,omitempty"` // deprecated alias for build
LastExecDuration *float64 `json:"last_exec_duration_secs,omitempty"` // deprecated alias for build
LastExecResult string `json:"last_exec_result,omitempty"` // deprecated alias for build
LastExecError string `json:"last_exec_error,omitempty"` // deprecated alias for build
LastStartTime *time.Time `json:"last_start_time,omitempty"`
LastFileChangeTime *time.Time `json:"last_file_change_time,omitempty"`
RestartCount int `json:"restart_count"`
BuildCount int `json:"build_count"`
TestCount int `json:"test_count"`
Links []Link `json:"links,omitempty"`
Logs *LogsConfig `json:"logs,omitempty"`
BackofficeReady bool `json:"backoffice_ready"`
}
TargetStatus is the JSON-serializable status of a target.