systemd

package
v1.34.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutostartUserUnits added in v1.9.0

func AutostartUserUnits() []string

AutostartUserUnits returns the lerd-* systemd user units (NOT podman quadlets) that participate in "autostart at login": lerd-ui, lerd-watcher, lerd-tray, and every per-site worker/queue/schedule/ horizon/reverb/stripe service file currently present in the user's systemd/user/ directory. These can be enabled/disabled with `systemctl --user enable/disable` because they are real on-disk unit files (not generator output).

Container quadlets are NOT in this list because their auto-start behaviour is controlled by stripping the [Install] section from the .container file (see podman.StripInstallSection), not by systemctl enable/disable. The autostart toggle handles quadlets via the global config flag and a quadlet rewrite pass.

func DBusActiveState added in v1.19.0

func DBusActiveState(name string) string

DBusActiveState returns the ActiveState property ("active", "inactive", "failed", "activating", …) for the named unit, or "" when the unit is unknown. Unit name may be bare (e.g. "lerd-foo") or fully-qualified ("lerd-foo.service", "lerd-foo.timer").

func DBusDaemonReload added in v1.19.0

func DBusDaemonReload() error

DBusDaemonReload runs systemctl --user daemon-reload over DBus.

func DBusDisableService added in v1.19.0

func DBusDisableService(name string) error

DBusDisableService removes a user service from the login start set.

func DBusEnableService added in v1.19.0

func DBusEnableService(name string) error

DBusEnableService marks a user service to start at login.

func DBusIsEnabled added in v1.19.0

func DBusIsEnabled(name string) bool

DBusIsEnabled returns true when the unit-file state resolves to "enabled".

func DBusResetFailed added in v1.19.0

func DBusResetFailed(name string) error

DBusResetFailed clears any "failed" state for the named unit so the next start is not blocked by Restart= rate-limits.

func DBusRestartUnit added in v1.19.0

func DBusRestartUnit(name string) error

DBusRestartUnit restarts a user unit via DBus.

func DBusStartUnit added in v1.19.0

func DBusStartUnit(name string) error

DBusStartUnit starts a user unit via DBus and waits for the job to finish.

func DBusStopUnit added in v1.19.0

func DBusStopUnit(name string) error

DBusStopUnit stops a user unit via DBus.

func DisableService added in v0.3.0

func DisableService(name string) error

DisableService disables a systemd user service.

func EnableService

func EnableService(name string) error

EnableService enables a systemd user service.

func EnsureNoNetworkWaitStall added in v1.29.0

func EnsureNoNetworkWaitStall() (bool, error)

EnsureNoNetworkWaitStall installs the override when podman's wait unit would otherwise stall every container start. Reports whether it wrote the drop-in.

func FindOrphanedWorkers added in v1.10.0

func FindOrphanedWorkers(siteName string, known map[string]bool) []string

FindOrphanedWorkers scans systemd unit files for worker units belonging to the given site that are running but not present in the known workers set.

func GetUnit

func GetUnit(name string) (string, error)

GetUnit returns the content of an embedded systemd unit file with the lerd binary path resolved. The templates ship with ExecStart=%h/.local/bin/lerd, which only works for a ~/.local/bin install; substituting the real path lets the daemon units run from any install location (notably /usr/bin under the Debian package).

func IsAutostartEnabled added in v1.9.0

func IsAutostartEnabled() bool

IsAutostartEnabled reports whether lerd is configured to come up at login. This is the inverse of cfg.Autostart.Disabled — the config flag is the canonical source of truth, not the live `systemctl is-enabled` state of any individual unit, because (a) container quadlets always report "generated" regardless of the wants symlink and (b) the flag must be readable even when no units exist on disk yet (fresh install).

func IsServiceActive added in v1.0.0

func IsServiceActive(name string) bool

IsServiceActive returns true if the systemd user service is currently active.

func IsServiceActiveOrRestarting added in v1.5.0

func IsServiceActiveOrRestarting(name string) bool

IsServiceActiveOrRestarting returns true if the service is active or in a restart loop (activating). Used to detect workers that should be stopped on unlink.

func IsServiceEnabled added in v0.3.0

func IsServiceEnabled(name string) bool

IsServiceEnabled returns true if the systemd user service is enabled.

func IsTimerActive added in v1.12.0

func IsTimerActive(name string) bool

IsTimerActive returns true if the worker's sibling .timer is active.

func NetworkWaitDropInPath added in v1.29.0

func NetworkWaitDropInPath() string

NetworkWaitDropInPath returns the path of lerd's override for podman's network-online wait unit.

func NetworkWaitStalls added in v1.29.0

func NetworkWaitStalls() bool

NetworkWaitStalls reports whether podman's network-online wait unit stalls container starts on this host.

func NotifyReady added in v1.19.0

func NotifyReady()

NotifyReady tells systemd the current process has finished its startup work and is ready to serve. Used by Type=notify units so systemctl start blocks until the service is actually up, not just spawned. No-op outside a systemd-managed process (returns false without error).

func NotifyStopping added in v1.19.0

func NotifyStopping()

NotifyStopping tells systemd the process is winding down, letting dependent units start their own teardown early instead of waiting for the process to actually exit.

func RemoveTimer added in v1.12.0

func RemoveTimer(name string) error

RemoveTimer removes a systemd user timer unit file.

func RestartService added in v0.6.0

func RestartService(name string) error

RestartService restarts a systemd user service.

func SessionIsIdle added in v1.19.0

func SessionIsIdle() bool

SessionIsIdle returns true when systemd-logind reports the current user's active session as idle (the compositor hasn't seen input for the configured idle timeout). Returns false when logind is unreachable or the session can't be identified, so callers behave as if the user is active when the signal is unavailable.

func SessionIsIdleOrLocked added in v1.19.0

func SessionIsIdleOrLocked() bool

SessionIsIdleOrLocked is a convenience combining both states.

func SessionIsLocked added in v1.19.0

func SessionIsLocked() bool

SessionIsLocked returns true when the user's session is locked by the screen locker. Returns false when the property is unreadable.

func StartService

func StartService(name string) error

StartService starts a systemd user service.

func SyncBootArming added in v1.34.0

func SyncBootArming(name string) error

SyncBootArming enables a unit for start at login, or disables it while autostart is off. A unit written after `lerd autostart disable` must not re-arm login start: at the next boot it comes up with no lerd services behind it and systemd restarts it forever. Disabling only drops the wants symlink, so a unit that is already running keeps running.

func UnitBelongsToOtherSiteWorktree added in v1.20.0

func UnitBelongsToOtherSiteWorktree(workerName, thisSite string, sites []config.Site) bool

UnitBelongsToOtherSiteWorktree reports whether the parsed candidate (workerName=<wname>-<parent>, thisSite=<wt>) is actually the worktree unit lerd-<wname>-<parent>-<wt>.service of another registered site.

func WriteService

func WriteService(name, content string) error

WriteService writes a systemd user service unit file.

func WriteServiceIfChanged added in v0.8.0

func WriteServiceIfChanged(name, content string) (bool, error)

WriteServiceIfChanged writes the unit file only when the content differs from what is already on disk. Returns true if the file was written (caller should run daemon-reload), false if it was unchanged (daemon-reload not needed).

func WriteTimerIfChanged added in v1.12.0

func WriteTimerIfChanged(name, content string) (bool, error)

WriteTimerIfChanged writes a systemd user timer unit file when its content differs from what is already on disk. Returns true when the file was written so the caller knows to run daemon-reload.

Types

type WorkerUnit added in v1.34.0

type WorkerUnit struct {
	Worker string
	Unit   string
}

WorkerUnit pairs a worker name with the unit file that carries it, so a caller that needs to act on the unit does not have to rebuild its name.

func StaleWorkerUnits added in v1.34.0

func StaleWorkerUnits(siteName string, declared map[string]bool) []WorkerUnit

StaleWorkerUnits returns every unit file left behind for a worker the site no longer declares, running or not. FindOrphanedWorkers answers the narrower question of what to offer stopping right now; this one answers what is still on disk, which is what a definition that dropped a worker leaves behind: armed for boot, walked by the self-heal detector, and removable only by hand.

Jump to

Keyboard shortcuts

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