Skip to main content

install

Function install 

Source
pub fn install(
    definition: &ServiceDefinition,
    password: Option<&str>,
) -> Result<Installed>
Expand description

Installs definition into this platform’s service manager and starts it (spec 3.2 §7.12), replacing an installed service of the same name.

password is the Windows account’s password, which the service control manager needs to run a service as that account; launchd and systemd ignore it. On Windows this needs an elevated shell, grants the account the “Log on as a service” right, and checks the password before registering the service. The log file is created owner-only where the service manager would create it.

§Errors

Returns KernelError::Service when the platform has no service form, the service manager refuses (its output is in the message), or, on Windows, without a password, an elevated shell, or for an account other than the current user.

§Example

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

let definition = ServiceDefinition::new("/usr/local/bin/adk-rust", "/srv/kernel");
let installed = install(&definition, std::env::var("ADK_SERVICE_PASSWORD").ok().as_deref())?;
println!("{} logs to {}", installed.name, installed.log.display());