initial commit
This commit is contained in:
commit
2a9f427bc7
21 changed files with 3692 additions and 0 deletions
45
src/main.rs
Normal file
45
src/main.rs
Normal file
|
@ -0,0 +1,45 @@
|
|||
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: {}")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue