From 2318a33f9b359ae27b52cd9a19db1f6782d8dae3 Mon Sep 17 00:00:00 2001 From: Vika Date: Thu, 1 Aug 2024 22:50:28 +0300 Subject: Upgrade dependencies and fix deprecated functionality I think I managed to not lose any functionality from my dependencies. sqlparser remains unupgraded, but that's mostly because it is only used in one example and it's not worth it to upgrade right now. --- src/main.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 4af8a81..f683c38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use base64::Engine; use kittybox::{database::Storage, indieauth::backend::AuthBackend, media::storage::MediaStore, webmentions::Webmention, compose_kittybox}; use tokio::{sync::Mutex, task::JoinSet}; -use std::{env, time::Duration, sync::Arc}; +use std::{env, future::IntoFuture, sync::Arc}; use tracing::error; @@ -208,7 +208,7 @@ async fn main() { } }; - let mut servers: Vec> = vec![]; + let mut servers: Vec> = vec![]; let build_hyper = |tcp: std::net::TcpListener| { tracing::info!("Listening on {}", tcp.local_addr().unwrap()); @@ -216,10 +216,14 @@ async fn main() { // properly -- this is the async magic! tcp.set_nonblocking(true).unwrap(); - hyper::server::Server::from_tcp(tcp).unwrap() - // Otherwise Chrome keeps connections open for too long - .tcp_keepalive(Some(Duration::from_secs(30 * 60))) - .serve(router.clone().into_make_service()) + //hyper::server::Server::from_tcp(tcp).unwrap() + // // Otherwise Chrome keeps connections open for too long + // .tcp_keepalive(Some(Duration::from_secs(30 * 60))) + // .serve(router.clone().into_make_service()) + axum::serve( + tokio::net::TcpListener::from_std(tcp).unwrap(), + router.clone() + ) }; let mut listenfd = listenfd::ListenFd::from_env(); @@ -286,19 +290,20 @@ async fn main() { .map( #[cfg(not(tokio_unstable))] |server| tokio::task::spawn( server.with_graceful_shutdown(cancellation_token.clone().cancelled_owned()) + .into_future() ), #[cfg(tokio_unstable)] |server| { tokio::task::Builder::new() - .name(format!("Kittybox HTTP acceptor: {}", server.local_addr()).as_str()) + .name(format!("Kittybox HTTP acceptor: {:?}", server).as_str()) .spawn( server.with_graceful_shutdown( cancellation_token.clone().cancelled_owned() - ) + ).into_future() ) .unwrap() } ) - .collect::>>>() + .collect::>>>() ); #[cfg(not(unix))] -- cgit 1.4.1