mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-12 18:45:41 +00:00
fix: terminate demo user job cleanly
This commit is contained in:
@@ -12,6 +12,7 @@ use actix_web::{
|
||||
error::InternalError, http::StatusCode, middleware as actix_middleware,
|
||||
web::JsonConfig, App, HttpServer,
|
||||
};
|
||||
use tokio::task::JoinHandle;
|
||||
use lazy_static::lazy_static;
|
||||
use log::info;
|
||||
|
||||
@@ -110,11 +111,11 @@ async fn main() -> std::io::Result<()> {
|
||||
let data = Data::new(&settings, secrets.clone()).await;
|
||||
let data = actix_web::web::Data::new(data);
|
||||
|
||||
let mut demo_user: Option<DemoUser> = None;
|
||||
let mut demo_user: Option<(DemoUser, JoinHandle<()>)> = None;
|
||||
|
||||
if settings.allow_demo && settings.allow_registration {
|
||||
demo_user = Some(
|
||||
DemoUser::spawn(data.clone(), Duration::from_secs(60 * 30))
|
||||
DemoUser::spawn(data.clone(), 60 * 30)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
@@ -156,7 +157,8 @@ async fn main() -> std::io::Result<()> {
|
||||
}
|
||||
|
||||
if let Some(demo_user) = demo_user {
|
||||
demo_user.abort();
|
||||
demo_user.0.abort();
|
||||
demo_user.1.await.unwrap();
|
||||
}
|
||||
|
||||
if let Some(survey_upload_handle) = survey_upload_handle {
|
||||
|
||||
Reference in New Issue
Block a user