// SPDX-FileCopyrightText: 2024 Simon Bruder // // SPDX-License-Identifier: AGPL-3.0-or-later use actix_web::HttpServer; use clap::Parser; use log::info; use li7y::Config; #[actix_web::main] async fn main() -> std::io::Result<()> { env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); let config = Config::parse(); // This can’t be included in app, because app gets called in a (non-async) closure let pool = sqlx::Pool::::connect(&config.database_url) .await .expect("failed to connect to database"); sqlx::migrate!() .run(&pool) .await .expect("failed to run migrations"); let address = config.listen_address; let port = config.listen_port; info!("Starting on {address}:{port}"); HttpServer::new(move || li7y::app(&config, &pool)) .bind((address, port))? .run() .await }