Merge branch '30-add-logging-to-startup-of-backend' into 'main'
Add logging Closes #30 See merge request libretunes/libretunes!22
This commit is contained in:
commit
9b1ea51896
@ -8,3 +8,4 @@
|
|||||||
!/style
|
!/style
|
||||||
!/Cargo.lock
|
!/Cargo.lock
|
||||||
!/Cargo.toml
|
!/Cargo.toml
|
||||||
|
!/ascii_art.txt
|
||||||
|
85
Cargo.lock
generated
85
Cargo.lock
generated
@ -44,6 +44,21 @@ version = "0.2.16"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
|
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android-tzdata"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android_system_properties"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.81"
|
version = "1.0.81"
|
||||||
@ -316,6 +331,18 @@ version = "1.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chrono"
|
||||||
|
version = "0.4.37"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e"
|
||||||
|
dependencies = [
|
||||||
|
"android-tzdata",
|
||||||
|
"iana-time-zone",
|
||||||
|
"num-traits",
|
||||||
|
"windows-targets 0.52.4",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ciborium"
|
name = "ciborium"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@ -422,6 +449,12 @@ dependencies = [
|
|||||||
"futures",
|
"futures",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "core-foundation-sys"
|
||||||
|
version = "0.8.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpufeatures"
|
name = "cpufeatures"
|
||||||
version = "0.2.12"
|
version = "0.2.12"
|
||||||
@ -613,6 +646,18 @@ version = "1.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flexi_logger"
|
||||||
|
version = "0.28.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f248c29a6d4bc5d065c9e9068d858761a0dcd796759f7801cc14db35db23abd8"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"glob",
|
||||||
|
"log",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "float-cmp"
|
name = "float-cmp"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
@ -796,6 +841,12 @@ version = "0.28.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
|
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glob"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gloo-net"
|
name = "gloo-net"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
@ -965,6 +1016,29 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone"
|
||||||
|
version = "0.1.60"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
|
||||||
|
dependencies = [
|
||||||
|
"android_system_properties",
|
||||||
|
"core-foundation-sys",
|
||||||
|
"iana-time-zone-haiku",
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone-haiku"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icondata"
|
name = "icondata"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
@ -1501,6 +1575,7 @@ dependencies = [
|
|||||||
"diesel",
|
"diesel",
|
||||||
"diesel_migrations",
|
"diesel_migrations",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
|
"flexi_logger",
|
||||||
"futures",
|
"futures",
|
||||||
"http",
|
"http",
|
||||||
"icondata",
|
"icondata",
|
||||||
@ -1510,6 +1585,7 @@ dependencies = [
|
|||||||
"leptos_icons",
|
"leptos_icons",
|
||||||
"leptos_meta",
|
"leptos_meta",
|
||||||
"leptos_router",
|
"leptos_router",
|
||||||
|
"log",
|
||||||
"openssl",
|
"openssl",
|
||||||
"pbkdf2",
|
"pbkdf2",
|
||||||
"serde",
|
"serde",
|
||||||
@ -3066,6 +3142,15 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-core"
|
||||||
|
version = "0.52.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.52.4",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
|
@ -36,6 +36,8 @@ tower-sessions = { version = "0.11", default-features = false }
|
|||||||
tower-sessions-redis-store = { version = "0.11", optional = true }
|
tower-sessions-redis-store = { version = "0.11", optional = true }
|
||||||
async-trait = "0.1.79"
|
async-trait = "0.1.79"
|
||||||
axum-login = { version = "0.14.0", optional = true }
|
axum-login = { version = "0.14.0", optional = true }
|
||||||
|
log = { version = "0.4.21", optional = true }
|
||||||
|
flexi_logger = { version = "0.28.0", optional = true, default-features = false }
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
gloo-net = { git = "https://github.com/rustwasm/gloo.git", rev = "a823fab7ecc4068e9a28bd669da5eaf3f0a56380" }
|
gloo-net = { git = "https://github.com/rustwasm/gloo.git", rev = "a823fab7ecc4068e9a28bd669da5eaf3f0a56380" }
|
||||||
@ -61,6 +63,8 @@ ssr = [
|
|||||||
"tower-http",
|
"tower-http",
|
||||||
"tower-sessions-redis-store",
|
"tower-sessions-redis-store",
|
||||||
"axum-login",
|
"axum-login",
|
||||||
|
"log",
|
||||||
|
"flexi_logger",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Defines a size-optimized profile for the WASM bundle in release mode
|
# Defines a size-optimized profile for the WASM bundle in release mode
|
||||||
|
@ -32,6 +32,7 @@ COPY style /app/style
|
|||||||
# Minify CSS
|
# Minify CSS
|
||||||
RUN npx tailwindcss -i /app/style/main.scss -o /app/style/main.scss --minify
|
RUN npx tailwindcss -i /app/style/main.scss -o /app/style/main.scss --minify
|
||||||
|
|
||||||
|
COPY ascii_art.txt /app/ascii_art.txt
|
||||||
COPY assets /app/assets
|
COPY assets /app/assets
|
||||||
COPY src /app/src
|
COPY src /app/src
|
||||||
COPY migrations /app/migrations
|
COPY migrations /app/migrations
|
||||||
|
10
ascii_art.txt
Normal file
10
ascii_art.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.-=. =+==-.
|
||||||
|
.=++++. =+++++=.
|
||||||
|
_ _ _ _______ =++++++= :*++++++=
|
||||||
|
| | (_) | |__ __| -++++**+. -+**++++-
|
||||||
|
| | _| |__ _ __ ___| |_ _ _ __ ___ ___ *+++**+ +**+++*
|
||||||
|
| | | | '_ \| '__/ _ \ | | | | '_ \ / _ \/ __| *+++**+ +**+++*
|
||||||
|
| |____| | |_) | | | __/ | |_| | | | | __/\__ \ -++++**+-: +**++++-
|
||||||
|
|______|_|_.__/|_| \___|_|\__,_|_| |_|\___||___/ =++++++**+ -+++++=
|
||||||
|
.=+++++++=.+++=.
|
||||||
|
.-==++++---.
|
15
src/main.rs
15
src/main.rs
@ -23,13 +23,23 @@ async fn main() {
|
|||||||
use tower_sessions_redis_store::{fred::prelude::*, RedisStore};
|
use tower_sessions_redis_store::{fred::prelude::*, RedisStore};
|
||||||
use axum_login::AuthManagerLayerBuilder;
|
use axum_login::AuthManagerLayerBuilder;
|
||||||
use libretunes::auth_backend::AuthBackend;
|
use libretunes::auth_backend::AuthBackend;
|
||||||
|
use log::*;
|
||||||
|
|
||||||
|
flexi_logger::Logger::try_with_env_or_str("debug").unwrap().format(flexi_logger::opt_format).start().unwrap();
|
||||||
|
|
||||||
|
info!("\n{}", include_str!("../ascii_art.txt"));
|
||||||
|
info!("Starting Leptos server...");
|
||||||
|
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
|
|
||||||
|
debug!("Running database migrations...");
|
||||||
|
|
||||||
// Bring the database up to date
|
// Bring the database up to date
|
||||||
libretunes::database::migrate();
|
libretunes::database::migrate();
|
||||||
|
|
||||||
|
debug!("Connecting to Redis...");
|
||||||
|
|
||||||
let redis_url = std::env::var("REDIS_URL").expect("REDIS_URL must be set");
|
let redis_url = std::env::var("REDIS_URL").expect("REDIS_URL must be set");
|
||||||
let redis_config = RedisConfig::from_url(&redis_url).expect(&format!("Unable to parse Redis URL: {}", redis_url));
|
let redis_config = RedisConfig::from_url(&redis_url).expect(&format!("Unable to parse Redis URL: {}", redis_url));
|
||||||
let redis_pool = RedisPool::new(redis_config, None, None, None, 1).expect("Unable to create Redis pool");
|
let redis_pool = RedisPool::new(redis_config, None, None, None, 1).expect("Unable to create Redis pool");
|
||||||
@ -55,9 +65,10 @@ async fn main() {
|
|||||||
.fallback(file_and_error_handler)
|
.fallback(file_and_error_handler)
|
||||||
.with_state(leptos_options);
|
.with_state(leptos_options);
|
||||||
|
|
||||||
println!("listening on http://{}", &addr);
|
|
||||||
|
|
||||||
let listener = tokio::net::TcpListener::bind(&addr).await.expect(&format!("Could not bind to {}", &addr));
|
let listener = tokio::net::TcpListener::bind(&addr).await.expect(&format!("Could not bind to {}", &addr));
|
||||||
|
|
||||||
|
info!("Listening on http://{}", &addr);
|
||||||
|
|
||||||
axum::serve(listener, app.into_make_service()).await.expect("Server failed");
|
axum::serve(listener, app.into_make_service()).await.expect("Server failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user