fix stdin handling for the tw watcher (#4119)
This commit is contained in:
1 parent
48e925f9af
commit
6b8919b37b
3 files changed
+15
-6
No files matched your search
@@ -203,7 +203,7 @@ pub(crate) async fn serve_all(args: ServeArgs, tracer: &mut TraceController) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
ServeUpdate::Exit { error } => {
|
ServeUpdate::Exit { error } => {
|
||||||
_ = builder.cleanup_all().await;
|
_ = builder.shutdown().await;
|
||||||
_ = devserver.shutdown().await;
|
_ = devserver.shutdown().await;
|
||||||
|
|
||||||
match error {
|
match error {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ pub(crate) struct AppServer {
|
|||||||
pub(crate) cross_origin_policy: bool,
|
pub(crate) cross_origin_policy: bool,
|
||||||
|
|
||||||
// Additional plugin-type tools
|
// Additional plugin-type tools
|
||||||
pub(crate) _tw_watcher: tokio::task::JoinHandle<Result<()>>,
|
pub(crate) tw_watcher: tokio::task::JoinHandle<Result<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct CachedFile {
|
pub(crate) struct CachedFile {
|
||||||
@@ -186,7 +186,7 @@ impl AppServer {
|
|||||||
_force_sequential: force_sequential,
|
_force_sequential: force_sequential,
|
||||||
cross_origin_policy,
|
cross_origin_policy,
|
||||||
fullstack,
|
fullstack,
|
||||||
_tw_watcher: tw_watcher,
|
tw_watcher,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only register the hot-reload stuff if we're watching the filesystem
|
// Only register the hot-reload stuff if we're watching the filesystem
|
||||||
@@ -564,7 +564,7 @@ impl AppServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Shutdown all the running processes
|
/// Shutdown all the running processes
|
||||||
pub(crate) async fn cleanup_all(&mut self) -> Result<()> {
|
pub(crate) async fn shutdown(&mut self) -> Result<()> {
|
||||||
self.client.soft_kill().await;
|
self.client.soft_kill().await;
|
||||||
|
|
||||||
if let Some(server) = self.server.as_mut() {
|
if let Some(server) = self.server.as_mut() {
|
||||||
@@ -588,6 +588,9 @@ impl AppServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// force the tailwind watcher to stop - if we don't, it eats our stdin
|
||||||
|
self.tw_watcher.abort();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,12 @@ impl TailwindCli {
|
|||||||
tailwind.install_github().await?;
|
tailwind.install_github().await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let proc = tailwind.watch(&manifest_dir, input_path, output_path)?;
|
// the tw watcher blocks on stdin, and `.wait()` will drop stdin
|
||||||
proc.wait_with_output().await?;
|
// unfortunately the tw watcher just deadlocks in this case, so we take the stdin manually
|
||||||
|
let mut proc = tailwind.watch(&manifest_dir, input_path, output_path)?;
|
||||||
|
let stdin = proc.stdin.take();
|
||||||
|
proc.wait().await?;
|
||||||
|
drop(stdin);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
@@ -107,6 +111,8 @@ impl TailwindCli {
|
|||||||
.arg("--output")
|
.arg("--output")
|
||||||
.arg(output_path)
|
.arg(output_path)
|
||||||
.arg("--watch")
|
.arg("--watch")
|
||||||
|
.kill_on_drop(true)
|
||||||
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
.stderr(Stdio::null())
|
.stderr(Stdio::null())
|
||||||
.spawn()?;
|
.spawn()?;
|
||||||
|
|||||||
Reference in new issue
Block a user