rdserver
: Add .healthcheck
route for monitoring purposes
This commit is contained in:
parent
d3126f8e2e
commit
0ac7a04477
2 changed files with 12 additions and 0 deletions
|
@ -21,6 +21,7 @@ async fn main() -> anyhow::Result<std::convert::Infallible> {
|
||||||
log::trace!("Creating Axum router...");
|
log::trace!("Creating Axum router...");
|
||||||
let app = axum::Router::new()
|
let app = axum::Router::new()
|
||||||
.route("/*path", axum::routing::get(route::webfinger_handler))
|
.route("/*path", axum::routing::get(route::webfinger_handler))
|
||||||
|
.route("/.healthcheck", axum::routing::get(route::healthcheck_handler))
|
||||||
.layer(Extension(Arc::new(mj)));
|
.layer(Extension(Arc::new(mj)));
|
||||||
log::trace!("Axum router created successfully!");
|
log::trace!("Axum router created successfully!");
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,17 @@ use acrate_rd::jrd::ResourceDescriptorLinkJRD;
|
||||||
use acrate_rd::xrd::{ResourceDescriptorLinkXRD, ResourceDescriptorPropertyXRD, ResourceDescriptorTitleXRD};
|
use acrate_rd::xrd::{ResourceDescriptorLinkXRD, ResourceDescriptorPropertyXRD, ResourceDescriptorTitleXRD};
|
||||||
use crate::config;
|
use crate::config;
|
||||||
|
|
||||||
|
pub async fn healthcheck_handler() -> Result<StatusCode, StatusCode> {
|
||||||
|
log::info!("Handling an healthcheck request!");
|
||||||
|
|
||||||
|
log::trace!("Making sure the database is up...");
|
||||||
|
let _conn = AsyncPgConnection::establish(config::ACRATE_WEBFINGER_DATABASE_URL())
|
||||||
|
.await
|
||||||
|
.map_err(|_| StatusCode::BAD_GATEWAY)?;
|
||||||
|
|
||||||
|
Ok(StatusCode::NO_CONTENT)
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct WebfingerQuery {
|
pub struct WebfingerQuery {
|
||||||
pub resource: Option<String>,
|
pub resource: Option<String>,
|
||||||
|
|
Loading…
Reference in a new issue