feat: polish logging if the server is unavailable
This commit is contained in:
parent
1229127101
commit
1bce912a1a
3 changed files with 8 additions and 8 deletions
|
|
@ -12,11 +12,7 @@ use tracing::Instrument;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
mc_server::{sanitize_addr, MinecraftAPI, MinecraftServerHandle, ServerDeploymentStatus},
|
mc_server::{sanitize_addr, MinecraftAPI, MinecraftServerHandle, ServerDeploymentStatus},
|
||||||
packets::{
|
packets::{clientbound::status::StatusTrait, SendPacket},
|
||||||
clientbound::status::StatusTrait,
|
|
||||||
serverbound::handshake::{self},
|
|
||||||
SendPacket,
|
|
||||||
},
|
|
||||||
OpaqueError,
|
OpaqueError,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -438,6 +434,7 @@ impl fmt::Debug for ServerDeploymentStatus {
|
||||||
Self::Starting => write!(f, "Starting"),
|
Self::Starting => write!(f, "Starting"),
|
||||||
Self::PodOk => write!(f, "PodOk"),
|
Self::PodOk => write!(f, "PodOk"),
|
||||||
Self::Offline => write!(f, "Offline"),
|
Self::Offline => write!(f, "Offline"),
|
||||||
|
Self::Unavailable(s) => write!(f, "Unavailable ({s})"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -235,9 +235,9 @@ async fn handle_status<T: MinecraftServerHandle>(
|
||||||
.instrument(span.clone())
|
.instrument(span.clone())
|
||||||
.await
|
.await
|
||||||
.map_err(|_| tracing::debug!("failed to send pong packet"));
|
.map_err(|_| tracing::debug!("failed to send pong packet"));
|
||||||
let _guard = span.enter();
|
|
||||||
|
|
||||||
tracing::info!(status = "unavailable", "status request");
|
let status = ServerDeploymentStatus::Unavailable(e.get_kind().to_string());
|
||||||
|
tracing::info!(status = ?status, "status request");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -264,6 +264,7 @@ async fn handle_status<T: MinecraftServerHandle>(
|
||||||
status_struct.description.text =
|
status_struct.description.text =
|
||||||
format!("{motd}\n§4Offline§r §oJoin to start!§r - {BYE_MESSAGE}");
|
format!("{motd}\n§4Offline§r §oJoin to start!§r - {BYE_MESSAGE}");
|
||||||
}
|
}
|
||||||
|
ServerDeploymentStatus::Unavailable(_) => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
mc_server::complete_status_request(client_stream, status_struct).await?;
|
mc_server::complete_status_request(client_stream, status_struct).await?;
|
||||||
|
|
@ -321,7 +322,7 @@ async fn handle_login<T: MinecraftServerHandle>(
|
||||||
|
|
||||||
match traffic.error {
|
match traffic.error {
|
||||||
Some(e) => {
|
Some(e) => {
|
||||||
tracing::info!(
|
tracing::warn!(
|
||||||
tx = traffic.tx,
|
tx = traffic.tx,
|
||||||
rx = traffic.rx,
|
rx = traffic.rx,
|
||||||
err = ?e,
|
err = ?e,
|
||||||
|
|
@ -344,6 +345,7 @@ async fn handle_login<T: MinecraftServerHandle>(
|
||||||
.await?;
|
.await?;
|
||||||
mc_server::send_disconnect(client_stream, format!("[\"\",{{\"text\":\"Okayy, §2starting§r the server!\n\n\"}},{{\"text\":\"{BYE_MESSAGE}\"}}]").as_str()).await?;
|
mc_server::send_disconnect(client_stream, format!("[\"\",{{\"text\":\"Okayy, §2starting§r the server!\n\n\"}},{{\"text\":\"{BYE_MESSAGE}\"}}]").as_str()).await?;
|
||||||
}
|
}
|
||||||
|
ServerDeploymentStatus::Unavailable(_) => unreachable!(),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,7 @@ pub enum ServerDeploymentStatus {
|
||||||
Starting,
|
Starting,
|
||||||
PodOk,
|
PodOk,
|
||||||
Offline,
|
Offline,
|
||||||
|
Unavailable(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sanitize_addr(addr: &str) -> &str {
|
pub fn sanitize_addr(addr: &str) -> &str {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue