Simon Bruder
b22588cd0d
All checks were successful
/ build (push) Successful in 1m55s
This makes integration testing much easier as it can reuse the app instance.
37 lines
968 B
Rust
37 lines
968 B
Rust
// SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
|
||
//
|
||
// 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::<sqlx::postgres::Postgres>::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
|
||
}
|