#[cfg(target_os = "windows")]
fn main() -> anyhow::Result<()> {
use clap::Parser;
use opcda_bridge_gateway::config::{Cli, ServiceCommand};
use opcda_bridge_gateway::{run, service};
let cli = Cli::parse();
if let Some(command) = &cli.command {
return match command {
ServiceCommand::Install => service::install(&cli),
ServiceCommand::Uninstall => service::uninstall(),
ServiceCommand::Start => service::start(),
ServiceCommand::Stop => service::stop(),
ServiceCommand::Status => service::status(),
};
}
match service::run_as_service() {
Ok(()) => Ok(()),
Err(e) if service::is_run_outside_scm(&e) => {
let rt = tokio::runtime::Runtime::new()?;
rt.block_on(run::run_gateway(cli, run::shutdown_signal()))
}
Err(e) => Err(e.into()),
}
}
#[cfg(not(target_os = "windows"))]
fn main() {
opcda_bridge_gateway::non_windows_run();
}