fix: 修复 http.rs 重启信号吞错(P1)
src/gateway/http.rs 的 /api/restart 处理器中:
let _ = restart_tx.send(true);
静默丢弃了 watch::Sender::send 的错误。
若接收方任务已退出(select! 其他分支先完成),
send 返回 Err 但 HTTP 已返回 success:true,
用户误以为重启成功,实际重启未触发,且无日志可排查。
改为 if let Err(e) = ... { tracing::warn!(...) } 记录错误。
保留 200ms 延迟设计(让 HTTP 响应先返回客户端),
不改变成功路径行为,仅在失败时增加诊断日志。
This commit is contained in:
parent
fef5ae7626
commit
47a30e87d8
@ -187,7 +187,13 @@ pub async fn restart(
|
|||||||
let restart_tx = state.restart_tx.clone();
|
let restart_tx = state.restart_tx.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
tokio::time::sleep(std::time::Duration::from_millis(200)).await;
|
tokio::time::sleep(std::time::Duration::from_millis(200)).await;
|
||||||
let _ = restart_tx.send(true);
|
if let Err(e) = restart_tx.send(true) {
|
||||||
|
tracing::warn!(
|
||||||
|
error = %e,
|
||||||
|
"Failed to send restart signal; receiver may have already exited. \
|
||||||
|
HTTP response already returned success, but restart may not occur."
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(Json(RestartResponse {
|
Ok(Json(RestartResponse {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user