Skip to main content

Module service

Module service 

Source
Expand description

Service installation (spec 3.2 §7.12, §10 W3): adk-rust up kept running by the platform’s service manager, as the user, logging to the kernel home and restarting on failure.

PlatformFormDefinitionStarts
macOSlaunchd agent~/Library/LaunchAgents/<name>.plistAt login, in the user’s session
Linuxsystemd user unit<config dir>/systemd/user/<name>.serviceWith the user’s service manager: at login, or at boot with lingering on
WindowsWindows service under the user’s accountThe service control managerAt boot (delayed automatic start)

Each form runs as the user, so a store key held in the OS keychain stays reachable: an agent rather than a daemon, a user unit, a service under the user’s account — which the service control manager needs that account’s password to start. Each writes the kernel’s output to <home>/kernel.log, created owner-only, and restarts the kernel when it exits with an error or dies: launchd’s KeepAlive on an unsuccessful exit, systemd’s Restart=on-failure, and the service’s failure actions (a restart after 5, 10 and 30 seconds; an exit with an error counts as a failure). Stopping the service drains the kernel as SIGTERM does.

ServiceDefinition::render shows what install registers, for any platform, without installing anything; adk-rust up --install --print prints it.

§Example

use adk_kernel::service::{ServiceDefinition, ServicePlatform};

let definition = ServiceDefinition::new("/usr/local/bin/adk-rust", "/home/ana/.config/adk-rust")
    .with_working_directory("/home/ana/project");
let unit = definition.render(ServicePlatform::Systemd);
assert!(unit.contains("ExecStart=/usr/local/bin/adk-rust up --home /home/ana/.config/adk-rust\n"));
assert!(unit.contains("Restart=on-failure\n"));
assert!(unit.contains("StandardOutput=append:/home/ana/.config/adk-rust/kernel.log\n"));

Structs§

Installed
What install did.
ServiceDefinition
What the service manager runs: adk-rust up with a kernel home (spec 3.2 §7.12).
Uninstalled
What uninstall did.

Enums§

ServicePlatform
A service manager the kernel installs into (spec 3.2 §7.12).

Constants§

LOG_FILE
The file under the kernel home the service writes the kernel’s output to.

Functions§

install
Installs definition into this platform’s service manager and starts it (spec 3.2 §7.12), replacing an installed service of the same name.
stop_requested
Resolves when the Windows service control manager asks this process, running as the kernel’s service, to stop or the system is shutting down (spec 3.2 §10 W3); never otherwise, and never on other platforms, whose service managers send SIGTERM. Kernel::shutdown_on_signal waits for it.
uninstall
Stops and removes the service name (spec 3.2 §7.12): the reverse of install. The kernel home, its stores and its log stay.