Add some more logs, configure dependencies and make certain variables be loaded at comp-time

This commit is contained in:
Lol3rrr
2024-10-13 22:41:26 +02:00
parent f301ad63c6
commit c4c32d5dae
4 changed files with 97 additions and 83 deletions

156
Cargo.lock generated
View File

@@ -152,12 +152,6 @@ dependencies = [
"syn",
]
[[package]]
name = "atomic-waker"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]]
name = "attribute-derive"
version = "0.9.2"
@@ -1206,25 +1200,6 @@ dependencies = [
"tracing",
]
[[package]]
name = "h2"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205"
dependencies = [
"atomic-waker",
"bytes",
"fnv",
"futures-core",
"futures-sink",
"http 1.1.0",
"indexmap",
"slab",
"tokio",
"tokio-util",
"tracing",
]
[[package]]
name = "half"
version = "2.4.1"
@@ -1361,7 +1336,7 @@ dependencies = [
"futures-channel",
"futures-core",
"futures-util",
"h2 0.3.26",
"h2",
"http 0.2.12",
"http-body 0.4.6",
"httparse",
@@ -1384,7 +1359,6 @@ dependencies = [
"bytes",
"futures-channel",
"futures-util",
"h2 0.4.6",
"http 1.1.0",
"http-body 1.0.1",
"httparse",
@@ -1411,6 +1385,7 @@ dependencies = [
"tokio",
"tokio-rustls",
"tower-service",
"webpki-roots",
]
[[package]]
@@ -1426,22 +1401,6 @@ dependencies = [
"tokio-native-tls",
]
[[package]]
name = "hyper-tls"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
dependencies = [
"bytes",
"http-body-util",
"hyper 1.4.1",
"hyper-util",
"native-tls",
"tokio",
"tokio-native-tls",
"tower-service",
]
[[package]]
name = "hyper-util"
version = "0.1.9"
@@ -1673,7 +1632,7 @@ dependencies = [
"once_cell",
"pad-adapter",
"paste",
"rustc-hash",
"rustc-hash 1.1.0",
"serde",
"serde_json",
"server_fn",
@@ -1739,7 +1698,7 @@ dependencies = [
"oco_ref",
"paste",
"pin-project",
"rustc-hash",
"rustc-hash 1.1.0",
"self_cell",
"serde",
"serde-wasm-bindgen",
@@ -2585,6 +2544,54 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
[[package]]
name = "quinn"
version = "0.11.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684"
dependencies = [
"bytes",
"pin-project-lite",
"quinn-proto",
"quinn-udp",
"rustc-hash 2.0.0",
"rustls",
"socket2",
"thiserror",
"tokio",
"tracing",
]
[[package]]
name = "quinn-proto"
version = "0.11.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6"
dependencies = [
"bytes",
"rand",
"ring",
"rustc-hash 2.0.0",
"rustls",
"slab",
"thiserror",
"tinyvec",
"tracing",
]
[[package]]
name = "quinn-udp"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b"
dependencies = [
"libc",
"once_cell",
"socket2",
"tracing",
"windows-sys 0.59.0",
]
[[package]]
name = "quote"
version = "1.0.37"
@@ -2788,11 +2795,11 @@ dependencies = [
"encoding_rs",
"futures-core",
"futures-util",
"h2 0.3.26",
"h2",
"http 0.2.12",
"http-body 0.4.6",
"hyper 0.14.30",
"hyper-tls 0.5.0",
"hyper-tls",
"ipnet",
"js-sys",
"log",
@@ -2806,7 +2813,7 @@ dependencies = [
"serde_json",
"serde_urlencoded",
"sync_wrapper 0.1.2",
"system-configuration 0.5.1",
"system-configuration",
"tokio",
"tokio-native-tls",
"tower-service",
@@ -2828,35 +2835,35 @@ dependencies = [
"encoding_rs",
"futures-core",
"futures-util",
"h2 0.4.6",
"http 1.1.0",
"http-body 1.0.1",
"http-body-util",
"hyper 1.4.1",
"hyper-rustls",
"hyper-tls 0.6.0",
"hyper-util",
"ipnet",
"js-sys",
"log",
"mime",
"native-tls",
"once_cell",
"percent-encoding",
"pin-project-lite",
"quinn",
"rustls",
"rustls-pemfile 2.2.0",
"rustls-pki-types",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper 1.0.1",
"system-configuration 0.6.1",
"tokio",
"tokio-native-tls",
"tokio-rustls",
"tower-service",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"webpki-roots",
"windows-registry",
]
@@ -2910,6 +2917,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc-hash"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
[[package]]
name = "rustix"
version = "0.38.37"
@@ -2930,6 +2943,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8"
dependencies = [
"once_cell",
"ring",
"rustls-pki-types",
"rustls-webpki",
"subtle",
@@ -3405,18 +3419,7 @@ checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"system-configuration-sys 0.5.0",
]
[[package]]
name = "system-configuration"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
dependencies = [
"bitflags 2.6.0",
"core-foundation",
"system-configuration-sys 0.6.0",
"system-configuration-sys",
]
[[package]]
@@ -3429,16 +3432,6 @@ dependencies = [
"libc",
]
[[package]]
name = "system-configuration-sys"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "system-deps"
version = "6.2.2"
@@ -3714,9 +3707,9 @@ dependencies = [
[[package]]
name = "tower-http"
version = "0.5.2"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5"
checksum = "8437150ab6bbc8c5f0f519e3d5ed4aa883a83dd4cdd3d1b21f9482936046cb97"
dependencies = [
"bitflags 2.6.0",
"bytes",
@@ -4159,6 +4152,15 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "webpki-roots"
version = "0.26.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958"
dependencies = [
"rustls-pki-types",
]
[[package]]
name = "weezl"
version = "0.1.8"

View File

@@ -9,9 +9,9 @@ axum = { version = "0.7.5", features = ["multipart"] }
serde = { version = "1.0.210", features = ["derive"] }
steam-openid = "0.2.0"
time = { version = "0.3.36", features = ["formatting", "parsing"] }
tokio = { version = "1.40.0", features = ["rt", "macros", "net", "mio"] }
tokio = { version = "1.40.0", features = ["rt", "macros", "net", "mio", "rt-multi-thread"] }
tower-sessions = "0.13.0"
tower-http = { version = "0.5", features = ["fs"] }
tower-http = { version = "0.6", features = ["fs"] }
tracing = { version = "0.1.40", features = ["async-await"] }
tracing-subscriber = "0.3.18"
futures-util = "0.3"
@@ -21,7 +21,7 @@ diesel-async = { version = "0.5", features = ["postgres"] }
serde_json = "1.0.128"
diesel_async_migrations = { version = "0.15" }
reqwest = { version = "0.12", features = ["json"] }
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "charset", "json"] }
common = { path = "../common/" }
analysis = { path = "../analysis/" }

View File

@@ -61,6 +61,9 @@ pub async fn run_api(
tokio::fs::create_dir_all(&upload_folder).await.unwrap();
}
let serve_dir = option_env!("FRONTEND_DIST_DIR").unwrap_or("../frontend/dist/");
tracing::debug!("Serving static files from {:?}", serve_dir);
let router = axum::Router::new()
.nest(
"/api/",
@@ -75,10 +78,13 @@ pub async fn run_api(
.layer(session_layer)
.nest_service(
"/",
tower_http::services::ServeDir::new("../frontend/dist/"),
tower_http::services::ServeDir::new(serve_dir),
);
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
let listen_addr = std::net::SocketAddr::new(std::net::IpAddr::V4(std::net::Ipv4Addr::new(0, 0, 0, 0)), 3000);
tracing::info!("Listening on Addr: {:?}", listen_addr);
let listener = tokio::net::TcpListener::bind(listen_addr).await.unwrap();
axum::serve(listener, router).await.unwrap();
}

View File

@@ -19,7 +19,7 @@ struct CliArgs {
analysis: bool,
}
#[tokio::main(flavor = "current_thread")]
#[tokio::main(flavor = "multi_thread")]
async fn main() {
use clap::Parser;
@@ -41,7 +41,10 @@ async fn main() {
let mut component_set = tokio::task::JoinSet::new();
tracing::info!("Starting modules");
if args.api {
tracing::info!("Enabled API module");
let steam_api_key = match std::env::var("STEAM_API_KEY") {
Ok(s) => s,
Err(e) => {
@@ -53,8 +56,11 @@ async fn main() {
component_set.spawn(backend::run_api(args.upload_folder.clone(), steam_api_key));
}
if args.analysis {
tracing::info!("Enabled Analysis module");
component_set.spawn(backend::run_analysis(args.upload_folder.clone()));
}
tracing::info!("Started modules");
component_set.join_all().await;
}