feat(web_ui): defer operator /compact to turn end, run when idle too
This commit is contained in:
parent
80d819e444
commit
faa7f982af
5 changed files with 77 additions and 79 deletions
|
|
@ -454,13 +454,10 @@ async fn serve_main<S: Surface>(socket: &Path, poll_ms: u64) -> Result<()> {
|
|||
login_state.clone(),
|
||||
bus.clone(),
|
||||
socket.to_path_buf(),
|
||||
files.clone(),
|
||||
turn_lock.clone(),
|
||||
);
|
||||
tokio::spawn(async move {
|
||||
let (label, port, login_state, bus, socket, files, turn_lock) = web_ui_args;
|
||||
if let Err(e) = web_ui::serve(label, port, login_state, bus, socket, files, turn_lock).await
|
||||
{
|
||||
let (label, port, login_state, bus, socket) = web_ui_args;
|
||||
if let Err(e) = web_ui::serve(label, port, login_state, bus, socket).await {
|
||||
tracing::error!(error = %e, "web_ui::serve exited with error");
|
||||
}
|
||||
});
|
||||
|
|
@ -517,7 +514,16 @@ async fn serve_loop<S: Surface>(
|
|||
None => match S::recv_next(socket).await {
|
||||
RecvOutcome::Message(first) => first,
|
||||
RecvOutcome::Empty => {
|
||||
tokio::time::sleep(interval).await;
|
||||
// Idle: no message this poll. Service a queued operator
|
||||
// `/compact` here so it runs even when no turn is driving
|
||||
// (the in-flight case is handled at the end of drive_turn).
|
||||
let compacted = {
|
||||
let _guard = turn_lock.lock().await;
|
||||
turn::run_pending_compact(files, &bus).await
|
||||
};
|
||||
if !compacted {
|
||||
tokio::time::sleep(interval).await;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
RecvOutcome::TransportError => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue