siteinfo

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllUnitStates added in v1.19.0

func AllUnitStates() map[string]string

AllUnitStates returns a snapshot of every cached lerd-* unit state (unit name → "active" | "inactive" | "failed" | …). The map is a copy safe for callers to walk without holding the cache mutex. Triggers a refresh if the cache is stale, but otherwise reuses the same batched systemctl snapshot the dashboard's enrichment path is already populating — zero extra subprocess cost for callers like the worker-health detector.

func DetectFavicon

func DetectFavicon(sitePath, publicDir, framework string, fw *config.Framework, hasFw bool) string

DetectFavicon returns the absolute path of the first favicon file found in the site's public directory, or empty string if none found. When fw/hasFw are not available, pass nil/false and the function will look them up from the framework name.

func FrameworkLabel

func FrameworkLabel(name, path string) string

FrameworkLabel returns the display label for a framework name. Exported for use by callers that need the label without full enrichment.

func InvalidateUnitCache added in v1.12.0

func InvalidateUnitCache()

InvalidateUnitCache forces the next UnitStatus lookup to re-run systemctl. Call this after any mutation that changes lerd-* unit state (start, stop, enable, disable, etc.) so cached "active" values do not go stale. Also invalidates any platform-specific cache (launchd states on darwin).

func KnownServices

func KnownServices() []string

KnownServices returns the built-in service names used for auto-detection. Backed by config.DefaultPresetNames so adding/removing a default preset flows through automatically.

func PersistVersionChanges

func PersistVersionChanges(sites []EnrichedSite) error

PersistVersionChanges writes back any detected version changes to the site registry.

Types

type ConflictingDomain

type ConflictingDomain struct {
	Domain  string
	OwnedBy string
}

ConflictingDomain describes a domain declared in .lerd.yaml that is owned by a different site on this machine.

type EnrichFlag

type EnrichFlag uint32

EnrichFlag controls which enrichment steps run during site loading.

const (
	EnrichFramework       EnrichFlag = 1 << iota // framework label + version
	EnrichVersions                               // live PHP/Node detection from disk
	EnrichWorkers                                // worker status via podman
	EnrichFPM                                    // FPM container running check
	EnrichGit                                    // worktrees + main branch
	EnrichServices                               // .env + .lerd.yaml service detection
	EnrichDomainConflicts                        // conflicting domain check
	EnrichLogs                                   // app log file detection
	EnrichFavicon                                // favicon detection
	EnrichStripe                                 // stripe secret check

	EnrichCLI = EnrichFramework | EnrichGit
	EnrichMCP = EnrichFramework | EnrichWorkers
	EnrichUI  = EnrichFramework | EnrichVersions | EnrichWorkers |
		EnrichFPM | EnrichGit | EnrichServices |
		EnrichDomainConflicts | EnrichLogs | EnrichFavicon | EnrichStripe
)

type EnrichedSite

type EnrichedSite struct {
	// Base fields from config.Site
	Name          string
	Domains       []string
	Path          string
	PHPVersion    string
	NodeVersion   string
	Secured       bool
	Paused        bool
	PausedWorkers []string
	PublicDir     string
	AppURL        string

	// Framework
	FrameworkName    string
	FrameworkLabel   string
	FrameworkVersion string

	// UsesPHP reports whether the site is actually a PHP project (composer.json
	// or .php files present) served by the shared FPM image or FrankenPHP.
	// Static sites and custom containers are false, so the UI can hide the PHP
	// version dropdown, Tinker, Xdebug, dumps and the FPM logs tab.
	UsesPHP bool

	// Runtime status
	FPMRunning bool

	// Well-known workers
	HasQueueWorker    bool
	QueueRunning      bool
	QueueFailing      bool
	HasScheduleWorker bool
	ScheduleRunning   bool
	ScheduleFailing   bool
	HasReverb         bool
	ReverbRunning     bool
	ReverbFailing     bool
	HasHorizon        bool
	HorizonRunning    bool
	HorizonFailing    bool
	StripeSecretSet   bool
	StripeRunning     bool

	// Custom framework workers
	FrameworkWorkers []WorkerInfo

	// Git
	Branch    string
	Worktrees []WorktreeInfo

	// Domain conflicts
	ConflictingDomains []ConflictingDomain

	// Services
	Services []string

	// Custom container
	ContainerPort  int
	ContainerSSL   bool
	ContainerImage string

	// Runtime — "" / "fpm" is the shared PHP-FPM image; "frankenphp" is the
	// per-site dunglas/frankenphp container. RuntimeWorker toggles worker mode
	// when running under frankenphp.
	Runtime       string
	RuntimeWorker bool

	// LAN sharing
	LANPort int

	// App metadata
	HasAppLogs    bool
	LatestLogTime string
	HasFavicon    bool

	// Version change tracking (for write-back by caller)
	PHPVersionChanged   bool
	NodeVersionChanged  bool
	OriginalPHPVersion  string
	OriginalNodeVersion string
}

EnrichedSite is the superset of site information needed by all surfaces.

func Enrich

func Enrich(s config.Site, flags EnrichFlag) EnrichedSite

Enrich populates an EnrichedSite from a config.Site according to the given flags.

func LoadAll

func LoadAll(flags EnrichFlag) ([]EnrichedSite, error)

LoadAll loads all non-ignored sites and enriches them according to flags.

func (*EnrichedSite) PrimaryDomain

func (e *EnrichedSite) PrimaryDomain() string

PrimaryDomain returns the first domain or empty string.

type WorkerInfo

type WorkerInfo struct {
	Name    string
	Label   string
	Running bool
	Failing bool
}

WorkerInfo describes a framework worker and its runtime state.

type WorktreeInfo

type WorktreeInfo struct {
	Branch              string
	Domain              string
	Path                string
	PHPVersion          string
	NodeVersion         string
	PHPVersionOverride  bool
	NodeVersionOverride bool
	FrameworkVersion    string
	FrameworkLabel      string
	DBIsolated          bool
	DBDatabase          string
	// LANPort, when non-zero, means a per-worktree reverse proxy is
	// listening on 0.0.0.0:LANPort. Independent of the parent's LAN port.
	LANPort int
	// Per-worktree worker state (lerd-<wname>-<site>-<wtBase>).
	// queue/schedule/reverb/horizon are excluded; those bind to the parent.
	FrameworkWorkers []WorkerInfo
}

WorktreeInfo describes a git worktree associated with a site. PHP/NodeVersion are the effective values (override or inherited); the *Override flags say which it is so callers can render an "inherited" hint.

Jump to

Keyboard shortcuts

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