This commit is contained in:
14
src/main.rs
14
src/main.rs
@@ -7,15 +7,21 @@ mod thumbnail;
|
||||
use actix_web::{middleware::Logger, web, App, HttpServer};
|
||||
use app_state::AppState;
|
||||
use handlers::{proxy_handler, upload_handler};
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
let app_state = AppState::new().await;
|
||||
|
||||
let app_state_clone = app_state.clone();
|
||||
tokio::spawn(async move {
|
||||
app_state_clone.update_filelist_from_aws().await;
|
||||
app_state_clone.refresh_file_list_periodically().await;
|
||||
|
||||
// Используем spawn_blocking для работы, которая не совместима с Send
|
||||
spawn_blocking(move || {
|
||||
let rt = tokio::runtime::Handle::current();
|
||||
rt.block_on(async move {
|
||||
app_state_clone.update_filelist_from_aws().await;
|
||||
app_state_clone.refresh_file_list_periodically().await;
|
||||
});
|
||||
});
|
||||
|
||||
HttpServer::new(move || {
|
||||
@@ -28,4 +34,4 @@ async fn main() -> std::io::Result<()> {
|
||||
.bind("127.0.0.1:8080")?
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user