minor healthcheck/docker fixes
This commit is contained in:
parent
cecaecb92e
commit
3003f4cf78
2 changed files with 27 additions and 13 deletions
|
@ -36,9 +36,9 @@ services:
|
||||||
links:
|
links:
|
||||||
- tsdb
|
- tsdb
|
||||||
|
|
||||||
prune:
|
task_prune:
|
||||||
image: ghcr.io/genudine/saerro/tasks:latest
|
image: ghcr.io/genudine/saerro/tasks:latest
|
||||||
command: prune
|
command: /app prune
|
||||||
pull_policy: always
|
pull_policy: always
|
||||||
restart: "no"
|
restart: "no"
|
||||||
environment:
|
environment:
|
||||||
|
|
|
@ -71,25 +71,39 @@ impl Health {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the websocket connection to the Nanite Systems manifold up?
|
/// Is the websocket processing jobs?
|
||||||
async fn websocket<'ctx>(&self, ctx: &Context<'ctx>) -> UpDown {
|
async fn ingest<'ctx>(&self, ctx: &Context<'ctx>) -> UpDown {
|
||||||
let pool = ctx.data::<Pool<Postgres>>().unwrap();
|
let pool = ctx.data::<Pool<Postgres>>().unwrap();
|
||||||
|
|
||||||
match query("SELECT count(*) FROM analytics WHERE time > now() - interval '5 minutes'")
|
let events_resp =
|
||||||
|
query("SELECT count(*) FROM analytics WHERE time > now() - interval '5 minutes'")
|
||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await;
|
||||||
{
|
|
||||||
Ok(i) => {
|
match events_resp {
|
||||||
let num: i64 = i.get(0);
|
Ok(row) => {
|
||||||
if num == 0 {
|
let events_row: i64 = row.get(0);
|
||||||
UpDown::Down
|
|
||||||
|
if events_row == 0 {
|
||||||
|
return UpDown::Down;
|
||||||
} else {
|
} else {
|
||||||
UpDown::Up
|
return UpDown::Up;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => UpDown::Down,
|
Err(_) => UpDown::Down,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Is the websocket actually turned on?
|
||||||
|
async fn ingest_reachable(&self) -> UpDown {
|
||||||
|
reqwest::get(
|
||||||
|
std::env::var("WEBSOCKET_HEALTHCHECK")
|
||||||
|
.unwrap_or("http://localhost:8999/health".to_string()),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map(|_| UpDown::Up)
|
||||||
|
.unwrap_or(UpDown::Down)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue