feat(agent): systemd service install/uninstall subcommands (alpha.11)
For Saturday's Ubuntu host + Linux VM: 'corrosion-host-agent install' writes a systemd unit (Type=simple — the agent already handles SIGTERM cleanly), daemon-reloads, and enables+starts the service; 'uninstall' reverses it. - new service.rs: pure unit_file_contents() generator (unit-tested) + Linux install/uninstall via systemctl; non-Linux returns a clear 'Linux only' error (Windows SCM is the follow-up). - ExecStart honors the resolved --config path (default or explicit). - Runs as root: the agent supervises game processes + their files, needs broad filesystem access. cargo check + service unit test green. Tag agent-v2.0.0-alpha.11 -> CI signs -> CDN /host-agent/alpha/. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
use corrosion_host_agent::{
|
||||
agent, bus, config, docker_compose, filemanager, hostcmd, instancecmd, prober, process,
|
||||
subjects, supervisor, telemetry, version,
|
||||
service, subjects, supervisor, telemetry, version,
|
||||
};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
@@ -37,6 +37,10 @@ enum Command {
|
||||
Check,
|
||||
/// Print full version (semver, git hash, build timestamp) and exit.
|
||||
Version,
|
||||
/// Install as a systemd service and start it (Linux; requires root).
|
||||
Install,
|
||||
/// Stop and remove the systemd service (Linux; requires root).
|
||||
Uninstall,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
@@ -58,6 +62,8 @@ fn main() -> Result<()> {
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
Some(Command::Install) => service::install(&config_path),
|
||||
Some(Command::Uninstall) => service::uninstall(),
|
||||
None => {
|
||||
let settings = config::load(&config_path)?;
|
||||
init_logging(&settings.log_level);
|
||||
|
||||
Reference in New Issue
Block a user