urma_node/daemon/
command.rs1#[cfg(windows)]
2use super::scm;
3#[cfg(not(windows))]
4use super::{ServeOptions, serve};
5#[cfg(not(windows))]
6use crate::platform::ServiceSettings;
7use crate::{Error, install, platform::Paths, service::ShutdownHandle};
8use std::{io::Write, path::PathBuf};
9
10#[derive(Clone, Debug, clap::Subcommand)]
11pub enum ServiceCommand {
12 Run {
15 #[arg(long, hide = true, default_value_os_t = Paths::system().settings)]
16 settings: PathBuf,
17 },
18 #[command(flatten)]
19 Manage(install::Action),
20}
21
22pub fn run(
26 settings: &std::path::Path,
27 signals: impl FnOnce(ShutdownHandle) -> Result<(), Error>,
28 log: &mut impl Write,
29) -> Result<(), Error> {
30 #[cfg(windows)]
31 {
32 scm::run(settings, signals, log)
33 }
34 #[cfg(not(windows))]
35 {
36 let options = ServeOptions::from_settings(ServiceSettings::read(settings)?);
37 serve(options, signals, log)
38 }
39}