add healthcheck endpoint and startup check

This commit is contained in:
2023-06-23 10:17:13 +02:00
parent e02224216a
commit e2711cc887
5 changed files with 39 additions and 2 deletions

View File

@@ -1,8 +1,10 @@
use actix_web::{
middleware::{self, Logger},
web, App, HttpServer,
web::{self},
App, HttpServer,
};
use dotenv::dotenv;
use log::error;
#[macro_use]
extern crate lazy_static;
@@ -10,6 +12,7 @@ extern crate lazy_static;
mod api;
mod client;
mod config;
mod health;
mod note;
mod size;
mod status;
@@ -20,6 +23,11 @@ async fn main() -> std::io::Result<()> {
dotenv().ok();
env_logger::init_from_env(env_logger::Env::new().default_filter_or(config::VERBOSITY.as_str()));
if !store::can_reach_redis() {
error!("cannot reach redis");
panic!("canont reach redis");
}
return HttpServer::new(|| {
App::new()
.wrap(Logger::new("\"%r\" %s %b %T"))