Improve active handling for controllers

This commit is contained in:
Tobias Reisinger 2023-11-28 00:19:15 +01:00
parent ec461a1a14
commit 6459804e1f
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
7 changed files with 87 additions and 35 deletions
emgauwa-core/src

View file

@ -5,6 +5,7 @@ use std::str::FromStr;
use crate::utils::drop_privileges;
use actix_web::middleware::TrailingSlash;
use actix_web::{middleware, web, App, HttpServer};
use emgauwa_lib::db::DbController;
use emgauwa_lib::handlers;
use log::{trace, LevelFilter};
use simple_logger::SimpleLogger;
@ -32,6 +33,14 @@ async fn main() -> std::io::Result<()> {
let pool = emgauwa_lib::db::init(&settings.database).await;
// This block is to ensure that the connection is dropped after use.
{
let mut conn = pool.acquire().await.unwrap();
DbController::all_inactive(&mut conn)
.await
.expect("Error setting all controllers inactive");
}
log::info!("Starting server on {}:{}", settings.host, settings.port);
HttpServer::new(move || {
let cors = Cors::default().allow_any_method().allow_any_header();