Fix 2265: close tui on success, custom tui subscriber (#2734)

This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-07-31 10:49:51 -07:00
1 parent 189772a17b
commit 63e7aab4e8
10 files changed
+226 -54

No files matched your search

+16 -2
View File
@@ -1,6 +1,7 @@
use crate::builder::{Stage, UpdateBuildProgress, UpdateStage};
use crate::cli::serve::Serve;
use crate::dioxus_crate::DioxusCrate;
use crate::tracer::CLILogControl;
use crate::Result;
use dioxus_cli_config::Platform;
use tokio::task::yield_now;
@@ -45,7 +46,11 @@ use watcher::*;
/// - Consume logs from the wasm for web/fullstack
/// - I want us to be able to detect a `server_fn` in the project and then upgrade from a static server
/// to a dynamic one on the fly.
pub async fn serve_all(serve: Serve, dioxus_crate: DioxusCrate) -> Result<()> {
pub async fn serve_all(
serve: Serve,
dioxus_crate: DioxusCrate,
log_control: CLILogControl,
) -> Result<()> {
let mut builder = Builder::new(&dioxus_crate, &serve);
// Start the first build
@@ -53,7 +58,7 @@ pub async fn serve_all(serve: Serve, dioxus_crate: DioxusCrate) -> Result<()> {
let mut server = Server::start(&serve, &dioxus_crate);
let mut watcher = Watcher::start(&serve, &dioxus_crate);
let mut screen = Output::start(&serve).expect("Failed to open terminal logger");
let mut screen = Output::start(&serve, log_control).expect("Failed to open terminal logger");
let is_hot_reload = serve.server_arguments.hot_reload.unwrap_or(true);
@@ -143,6 +148,15 @@ pub async fn serve_all(serve: Serve, dioxus_crate: DioxusCrate) -> Result<()> {
// And then finally tell the server to reload
server.send_reload_command().await;
},
// If the process exited *cleanly*, we can exit
Ok(BuilderUpdate::ProcessExited { status, ..}) => {
if let Some(status) = status {
if status.success() {
break;
}
}
}
Err(err) => {
server.send_build_error(err).await;
}