liftinstall/src/frontend/mod.rs
2021-10-15 04:35:47 -06:00

30 lines
877 B
Rust

//! frontend/mod.rs
//!
//! Provides the frontend interface, including HTTP server.
use std::sync::{Arc, RwLock};
use crate::installer::InstallerFramework;
use crate::logging::LoggingErrors;
pub mod rest;
mod ui;
/// Launches the main web server + UI. Returns when the framework has been consumed + web UI closed.
pub fn launch(app_name: &str, is_launcher: bool, framework: InstallerFramework) {
let framework = Arc::new(RwLock::new(framework));
let (servers, address) = rest::server::spawn_servers(framework.clone());
ui::start_ui(app_name, &address, is_launcher).log_expect("Failed to start UI");
// Explicitly hint that we want the servers instance until here.
drop(servers);
framework
.write()
.log_expect("Failed to write to framework to finalize")
.shutdown()
.log_expect("Failed to finalize framework");
}