Improve active handling for controllers
This commit is contained in:
parent
ec461a1a14
commit
6459804e1f
7 changed files with 87 additions and 35 deletions
emgauwa-core/src
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue