Documentation
¶
Index ¶
- func AllUnitStates() map[string]string
- func DetectFavicon(sitePath, publicDir, framework string, fw *config.Framework, hasFw bool) string
- func FrameworkLabel(name, path string) string
- func InvalidateUnitCache()
- func KnownServices() []string
- func LaravelAppName(frameworkName, sitePath string) string
- func PersistVersionChanges(sites []EnrichedSite) error
- type ConflictingDomain
- type EnrichFlag
- type EnrichedSite
- type WorkerInfo
- type WorktreeInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllUnitStates ¶ added in v1.19.0
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 ¶
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 ¶
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 LaravelAppName ¶ added in v1.25.0
LaravelAppName reads APP_NAME from a Laravel project's .env so a surface can label a site by its application name instead of just the URL. Returns "" for non-Laravel projects, a missing .env or APP_NAME, and the stock "Laravel" default, which keeps the label purely additive: uncustomised sites stay titled by their scannable domain rather than a wall of identical names.
The result is cached against the .env's mod time, so a steady-state dashboard poll costs one stat per site rather than an open-and-parse of the whole file.
func PersistVersionChanges ¶
func PersistVersionChanges(sites []EnrichedSite) error
PersistVersionChanges writes back any detected version changes to the site registry.
Types ¶
type ConflictingDomain ¶
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
// FrameworkPHPMin/Max are the framework's supported PHP range, so the UI and
// TUI can disable out-of-range versions. Empty when the version was guessed
// (clamped), since the range then belongs to a different version.
FrameworkPHPMin string
FrameworkPHPMax 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
StripeWebhookPath string
// Custom framework workers
FrameworkWorkers []WorkerInfo
// Idle suspension — IdleSuspendedWorkers names the parent-site workers the
// idle engine gracefully stopped (queue, schedule, vite, …) so a row can
// show "suspended" rather than a misleading "stopped". WorktreeIdleSuspended
// is the same, keyed by each worktree's unit slug, consumed by enrichGit.
IdleSuspendedWorkers []string
WorktreeIdleSuspended map[string][]string
// Grouping — Group is the group key (the main site's name); GroupSubdomain
// is the label a secondary occupies on the main's base domain.
Group string
GroupSubdomain string
// Git
Branch string
Worktrees []WorktreeInfo
// Domain conflicts
ConflictingDomains []ConflictingDomain
// Services
Services []string
// Custom container
ContainerPort int
ContainerSSL bool
ContainerImage string
// Host proxy — non-zero HostPort means nginx proxies the domain to a dev
// server lerd supervises on the host (the "app" worker).
HostPort int
HostSSL bool
HostCommand 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
// AppName is the Laravel APP_NAME from .env, or "" for non-Laravel sites and
// for the stock "Laravel" default, so a surface can title a site by its
// application name without burying customised ones under identical defaults.
AppName string
// 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 ¶
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
// IdleSuspended names the worktree's workers the idle engine stopped, so a
// row can read "suspended" instead of "stopped".
IdleSuspended []string
}
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.