feat: with monitoring

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-08-27 00:07:56 +02:00
parent 569f5272e6
commit e0545c726c
8 changed files with 145 additions and 11 deletions

View File

@@ -14,3 +14,4 @@ clap.workspace = true
dotenv.workspace = true
axum.workspace = true
reqwest.workspace = true
uuid.workspace = true

View File

@@ -113,9 +113,9 @@ async fn handle_command(cmd: Command) -> anyhow::Result<()> {
} => {
tracing::info!("monitoring server: {}", server);
let mut cursor: Option<String> = None;
let mut cursor: Option<uuid::Uuid> = None;
loop {
tracing::info!("reading logs from server: {}", server);
tracing::debug!("reading logs from server: {}", server);
let resp = reqwest::get(format!(
"{server}/logs{}",
@@ -136,9 +136,9 @@ async fn handle_command(cmd: Command) -> anyhow::Result<()> {
match resp.json::<ServerMonitorResp>().await {
Ok(resp) => {
for line in resp.logs {
tracing::info!("server: {}", line);
tracing::info!("event: {}", line);
}
cursor = Some(resp.cursor);
cursor = resp.cursor;
}
Err(e) => {
tracing::warn!("failed to call server (error={})", e);