mirror of
https://github.com/shiroyashik/sculptor.git
synced 2025-12-06 13:01:12 +03:00
Add health check endpoint
This commit is contained in:
parent
917c69f11a
commit
84979849eb
1 changed files with 9 additions and 0 deletions
|
|
@ -94,6 +94,14 @@ pub struct AppState {
|
||||||
advanced_users: Arc<Mutex<toml::Table>>,
|
advanced_users: Arc<Mutex<toml::Table>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Assert health of the server
|
||||||
|
/// If times out, the server is considered dead, so we can return basically anything
|
||||||
|
async fn health_check() -> String {
|
||||||
|
// tokio::time::sleep(std::time::Duration::from_secs(5)).await;
|
||||||
|
"ok".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
tracing_subscriber::fmt::fmt()
|
tracing_subscriber::fmt::fmt()
|
||||||
|
|
@ -148,6 +156,7 @@ async fn main() -> Result<()> {
|
||||||
.nest("/api", api)
|
.nest("/api", api)
|
||||||
.route("/api/", get(api_auth::status))
|
.route("/api/", get(api_auth::status))
|
||||||
.route("/ws", get(handler))
|
.route("/ws", get(handler))
|
||||||
|
.route("/health", get(health_check))
|
||||||
.route_layer(from_extractor::<api_auth::Token>())
|
.route_layer(from_extractor::<api_auth::Token>())
|
||||||
.with_state(state)
|
.with_state(state)
|
||||||
.layer(TraceLayer::new_for_http().on_request(()));
|
.layer(TraceLayer::new_for_http().on_request(()));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue