Expand description
lev daemon install / lev daemon uninstall - hand the daemon to the OS
supervisor so it comes back by itself after a crash.
Without supervision, nothing restarts the daemon when it dies: a
long-running agent simply stops, and the next lev run is the only thing
that brings the daemon back. Registering a launchd agent (macOS) or a systemd user
unit (Linux) with a restart policy closes that gap - and on the next start
the daemon’s own recovery pass reloads every interrupted run.
This module is the tested core: rendering the unit file, resolving where it goes, writing/removing it, and building the activation command line. Running that command is real subprocess I/O and lives in the binary.
Platform differences are #[cfg]-gated rather than branched at runtime, so
each target compiles exactly the code it uses (and covers all of it).
Structs§
- Service
Unit - A rendered service definition and where it belongs.
Constants§
- SERVICE_
LABEL - The reverse-DNS label both platforms key the service by.
Functions§
- config_
home - Where the unit file goes, relative to the user’s home directory.
- format_
supervision - The line
lev daemon statusadds about supervision. - install
- Write
unitto disk, creating its parent directory. Returns the path. - install_
with - Register the service with the platform supervisor, returning the lines to report.
- service_
unit - Build the service definition for this platform (see the macOS variant for
the argument contract;
uidis unused here - systemd’s--usermode already addresses the calling user’s manager). - supervisor_
failure - Turn a failed supervisor command into the error the user reads.
- systemd_
unit - A systemd user unit (no root needed) with the same restart policy.
- uninstall
- Remove the unit file. Returns whether there was one to remove.
- uninstall_
with - Deregister the service and remove its file, returning the lines to report.
- unit_
safe - Reject a value that cannot be safely interpolated into a systemd unit file.
Type Aliases§
- Supervisor
Command - A supervisor invocation: the program to run and its arguments.