diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 23 |
1 files changed, 14 insertions, 9 deletions
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<hyper::server::Server<hyper::server::conn::AddrIncoming, _>> = vec![]; + let mut servers: Vec<axum::serve::Serve<_, _>> = 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::<futures_util::stream::FuturesUnordered<tokio::task::JoinHandle<Result<(), hyper::Error>>>>() + .collect::<futures_util::stream::FuturesUnordered<tokio::task::JoinHandle<Result<(), std::io::Error>>>>() ); #[cfg(not(unix))] |