use std::net::SocketAddr; use crate::{config::PenguinConfig, feeds::enrich_feeds}; mod app; mod config; mod feeds; mod hash; mod logging; mod routes; mod scrapers; mod signals; mod templates; #[tokio::main] async fn main() { logging::setup("findpenguins_feed"); let config = PenguinConfig::read().expect("Failed to read application configuration"); let addr = get_addr(&config); let feeds = enrich_feeds(config.feeds).await; let app = app::create(feeds); tracing::debug!("Listening on {}", addr); axum::Server::bind(&addr) .serve(app.into_make_service()) .with_graceful_shutdown(signals::shutdown()) .await .expect("Failed to start server"); } /// Retrieve the address to listen on. /// /// # Returns /// /// A `SocketAddr` object that represents the address to listen on. /// /// # Panics /// /// If the `host` string cannot be parsed into a `SocketAddr` object. fn get_addr(config: &PenguinConfig) -> SocketAddr { config .server_address .parse() .expect("No proper address to listen on: {}") }