-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rs
46 lines (36 loc) · 1.26 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#![deny(clippy::unwrap_used)]
#![deny(clippy::expect_used)]
// TODO: support different lua versions
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
mod common;
mod requests;
mod responses;
mod routes;
mod utils;
#[tokio::main]
async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
format!("{}=debug,tower_http=debug", env!("CARGO_CRATE_NAME")).into()
}),
)
.with(tracing_subscriber::fmt::layer())
.init();
common::init().await;
let mut listener_address = "127.0.0.1:8080".to_string();
if let Ok(settings) = common::LUA.globals().get::<mlua::Table>("Astra") {
if let Ok(hostname) = settings.get::<String>("hostname") {
if let Ok(port) = settings.get::<u16>("port") {
listener_address = format!("{hostname}:{port}");
}
}
}
#[allow(clippy::unwrap_used)]
let listener = tokio::net::TcpListener::bind(listener_address.clone())
.await
.unwrap();
println!("🚀 Listening at: http://{listener_address}");
#[allow(clippy::unwrap_used)]
axum::serve(listener, routes::load_routes()).await.unwrap();
}