Documentation
¶
Index ¶
- Variables
- func RefreshWorktreeIndex()
- func SetLogger(l *slog.Logger)
- func StartIdle(notify func(), sourceWatcher func(stop <-chan struct{}) error)
- func Watch(dirs []string, onNew func(path string), onRemoved func(path string)) error
- func WatchCleanup(interval time.Duration)
- func WatchDNS(interval time.Duration, tld string)
- func WatchExecWorkers(_ time.Duration)
- func WatchHostGateway(interval time.Duration, stop <-chan struct{})
- func WatchSiteFiles(getSites func() []string, debounce time.Duration, ...) error
- func WatchSourceFiles(getTargets func() []SourceTarget, debounce time.Duration, ...) error
- func WatchWorktrees(getSites func() []string, onAdded func(sitePath, name string), ...) error
- type SourceTarget
Constants ¶
This section is empty.
Variables ¶
var OnGatewayIPChange func()
OnGatewayIPChange, if set, runs after the shared hosts file is rewritten with a fresh host-gateway IP. The cli package wires this (via main) to regenerate host-proxy vhosts, which bake the gateway IP into proxy_pass on Linux and would otherwise point at a dead address until the next manual regen.
Functions ¶
func RefreshWorktreeIndex ¶ added in v1.29.0
func RefreshWorktreeIndex()
RefreshWorktreeIndex re-detects worktrees now. The daemon calls it whenever a worktree is added, changed or removed, so a new worktree's traffic is attributed from its first request rather than from the next scheduled refresh.
func SetLogger ¶ added in v0.9.0
SetLogger replaces the watcher logger. Call before starting any watchers.
func StartIdle ¶ added in v1.25.0
func StartIdle(notify func(), sourceWatcher func(stop <-chan struct{}) error)
StartIdle wires the idle subsystem: the control socket is always bound, while the session (access feed, tick, source watcher) only runs when enabled. sourceWatcher runs until its stop channel closes.
func Watch ¶
Watch monitors the given directories for new and deleted project subdirectories. onNew is called when a framework signal file appears in a direct subdirectory of a parked dir. onRemoved is called when a watched subdirectory is deleted.
func WatchCleanup ¶ added in v1.27.0
WatchCleanup periodically reclaims orphaned lerd images and unused service images (the managed tier). It ticks at interval but acts at most once per autoCleanupInterval, throttled by a persisted timestamp so a restarting watcher can't sweep more often. The auto_cleanup config gate turns it off.
func WatchDNS ¶ added in v0.8.2
WatchDNS polls DNS health for the given TLD every interval. When resolution is broken it waits for lerd-dns to be ready and re-applies the resolver configuration, replicating the DNS repair done by lerd start. When the user session is idle or locked it backs off to one probe every 10 ticks so laptops don't pay the per-30s DNS lookup battery cost while away.
On Linux it also subscribes to rtnetlink link and address changes via linkChanges, so a VPN connect or disconnect kicks an immediate tick instead of waiting up to interval for the next poll. The poll stays as a safety net so a missed netlink event can't strand the system.
Every observed transition and every successful repair publishes eventbus.KindStatus so the dashboard reflects the live state via the WebSocket without a manual refresh.
func WatchExecWorkers ¶ added in v1.19.0
WatchExecWorkers is a no-op on Linux. Workers run as systemd services with Restart=always under their own supervisor — no out-of-band heal needed and no podman-machine bridge to wedge.
func WatchHostGateway ¶ added in v1.15.1
WatchHostGateway keeps both addresses in the shared hosts files fresh: lerd-nginx's bridge IP, and the host.containers.internal gateway that Xdebug needs. Costs one podman inspect per tick; the exec probe stays LAN-gated. Runs until stop is closed; pass nil to run forever.
func WatchSiteFiles ¶ added in v0.8.0
func WatchSiteFiles(getSites func() []string, debounce time.Duration, onChanged func(sitePath string)) error
WatchSiteFiles monitors key config files in each site directory returned by getSites. onChanged is called at most once per debounce period per site when any of the watched files are written or replaced.
func WatchSourceFiles ¶ added in v1.25.0
func WatchSourceFiles(getTargets func() []SourceTarget, debounce time.Duration, onActivity func(key string), stop <-chan struct{}) error
WatchSourceFiles watches each target's source directories recursively and calls onActivity(key), debounced per key, when a source file under them is written, created, or renamed — i.e. when you save while coding. Heavy or generated subtrees (node_modules, vendor, hidden dirs, ...) are never descended, so the watch set stays small, which also keeps macOS kqueue descriptor use bounded. Targets are re-scanned periodically so new sites/worktrees and newly-created subdirectories are picked up. It runs until stop is closed (idle-suspend disabled), then releases all fsnotify watches.
func WatchWorktrees ¶ added in v0.6.0
func WatchWorktrees( getSites func() []string, onAdded func(sitePath, name string), onChanged func(sitePath, name string), onRemoved func(sitePath, name string), ) error
WatchWorktrees monitors the .git/worktrees/ directory for each site returned by getSites and calls onAdded/onRemoved when entries appear or disappear. It calls onChanged when worktree metadata changes, such as HEAD being rewritten by a branch rename. It also watches .git/ itself so it can re-attach to .git/worktrees/ if it is deleted (last worktree removed) and then re-created (first new worktree added). It re-polls getSites every 30 seconds to pick up newly registered sites.
Types ¶
type SourceTarget ¶ added in v1.25.0
SourceTarget is one checkout whose source tree is watched for edits. Key is the idle-activity key — a site name, or "site/wtBase" for a worktree — and Dirs are the absolute source roots to watch recursively.