lifecycle

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const TeardownOnLogout = false

TeardownOnLogout is false on Linux. There is no VM outliving the session to protect, and systemd already stops the container units as the user manager goes away, so a teardown here buys nothing and costs a real footgun: every SIGTERM the watcher gets is indistinguishable, so an ordinary `systemctl --user stop lerd-watcher` would stop every container, lerd-ui and lerd-dns with it.

Variables

This section is empty.

Functions

func ActivePHPVersions

func ActivePHPVersions() map[string]bool

ActivePHPVersions returns the set of PHP versions actually in use by non-ignored, non-paused sites, using live disk detection (.php-version file) with the stored registry value as fallback.

func AllInstalledServiceUnits

func AllInstalledServiceUnits() []string

AllInstalledServiceUnits returns all service units that have a unit file installed, regardless of paused state. Used for lerd stop.

func BatchStopContainers

func BatchStopContainers(_ []string)

BatchStopContainers is a no-op on Linux — systemd stops containers via unit deactivation so individual StopUnit calls are efficient and non-blocking.

func CoreUnits

func CoreUnits() []string

CoreUnits returns the container units managed by lerd start/stop. Does not include lerd-ui or lerd-watcher — those are added separately in runStart. The configured default PHP version is ALWAYS included so the `php`, `composer`, and `laravel new` shims have a working FPM container even on a fresh install with zero registered sites. Other installed versions are only started when at least one site references them; unused versions are left stopped.

func InstalledCustomContainerUnits

func InstalledCustomContainerUnits() []string

InstalledCustomContainerUnits returns units for per-project custom containers and per-site FrankenPHP containers that have a unit file installed (plist on macOS, quadlet on Linux). These are started alongside FPM and services.

func InstalledServiceUnits

func InstalledServiceUnits() []string

InstalledServiceUnits returns service units that have a unit file installed and have not been manually stopped by the user. Used for lerd start.

func Quit

func Quit(runner ParallelRunner, beforeMachineStop func(), skip ...string) error

Quit is the full teardown behind `lerd quit`: everything Stop covers, then the host process units, then the Podman Machine VM. skip removes units the caller must not stop. beforeMachineStop, when set, runs after the process units and before the VM, for host cleanup that must not wait out a VM stop that takes seconds; pass nil when there is none.

func QuitProcessUnits

func QuitProcessUnits(skip ...string) []string

QuitProcessUnits is the ordered set of host process units `lerd quit` tears down after Stop. Unlike `lerd stop`, quit is a full teardown, so it includes lerd-dns. lerd-watcher precedes lerd-dns because the watcher is the only thing that restarts lerd-dns; stopping it first keeps dns down. skip removes units the caller must not stop, for a daemon quitting from inside one of them.

func RegisteredFrameworkWorkerUnits

func RegisteredFrameworkWorkerUnits() []string

RegisteredFrameworkWorkerUnits returns lerd-{worker}-{site} unit names for every site/worker pair declared in the site registry. Used to make sure non-standard workers (horizon, vite-dev, etc.) get started in phase 2 of runStart, not just the queue/stripe/schedule/reverb glob.

func RegisteredQueueUnits

func RegisteredQueueUnits() []string

RegisteredQueueUnits returns unit names for all lerd-queue-* service units (i.e. started via `lerd queue:start`).

func RegisteredReverbUnits

func RegisteredReverbUnits() []string

RegisteredReverbUnits returns unit names for all lerd-reverb-* service units.

func RegisteredScheduleUnits

func RegisteredScheduleUnits() []string

RegisteredScheduleUnits returns unit names for all lerd-schedule-* service units.

func RegisteredStripeUnits

func RegisteredStripeUnits() []string

RegisteredStripeUnits returns unit names for all lerd-stripe-* service units.

func RegisteredTimerUnits

func RegisteredTimerUnits() []string

RegisteredTimerUnits returns names for every lerd-* timer unit on disk, each with the explicit `.timer` suffix so callers pass them straight to systemctl. These drive scheduled (cron-style) framework workers like Laravel <=10's `php artisan schedule:run`.

func ShutdownForLogout

func ShutdownForLogout(runner ParallelRunner) error

ShutdownForLogout is the teardown the watcher runs when the OS is logging out or restarting. It differs from Quit in two ways that both matter only when the shutdown is driven from inside lerd-watcher.

It never stops podman.WatcherUnit, and it stops the Podman Machine VM before the host process units rather than after. The VM is the only step whose loss costs anything: a database killed mid-write replays its write-ahead log for minutes on the next start. lerd-ui, lerd-dns and lerd-tray are host processes that launchd is terminating anyway, so they are the right thing to leave until last if the exit grace runs out.

func SimpleRunner

func SimpleRunner(jobs []Job) error

SimpleRunner runs jobs concurrently with no spinner UI, for daemons tearing lerd down in the background. Every job runs even when an earlier one fails: a unit that refuses to stop must not strand the units behind it.

func Stop

func Stop(runner ParallelRunner, skip ...string) error

Stop tears down every container, service, and worker unit, running the per-unit stops through runner. skip removes units the caller must not stop.

func StopPodmanMachine

func StopPodmanMachine()

StopPodmanMachine is a no-op on Linux — Podman runs natively without a VM.

func StopUnitSet

func StopUnitSet(skip ...string) []string

StopUnitSet returns every unit `lerd stop` tears down. lerd-dns is deliberately excluded: the resolver points .test at it until uninstall, so it stays up as install-level DNS plumbing (the watcher would restart it).

Types

type Job

type Job struct {
	Label string
	Run   func(w io.Writer) error
}

Job represents a unit of work that can be run in parallel.

type ParallelRunner

type ParallelRunner func(jobs []Job) error

ParallelRunner executes jobs in parallel.

Jump to

Keyboard shortcuts

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