Create health check bin

This commit is contained in:
2025-05-03 05:59:54 +00:00
parent e2a395ae7c
commit 7bccde7654
2 changed files with 34 additions and 0 deletions

View File

@ -19,6 +19,11 @@ opt-level = 3
[lib]
crate-type = ["cdylib", "rlib"]
[[bin]]
name = "health_check"
path = "src/health.rs"
required-features = ["health_check"]
[dependencies]
console_error_panic_hook = { version = "0.1", optional = true }
cfg-if = "1"
@ -100,6 +105,12 @@ reqwest_api = [
# (which is useful for code editors checking for errors)
"server_fn/reqwest"
]
health_check = [
"reqwest_api",
"tokio",
"tokio/rt",
"tokio/macros",
]
# Defines a size-optimized profile for the WASM bundle in release mode
[profile.wasm-release]
@ -146,6 +157,8 @@ browserquery = "defaults"
watch = false
# The environment Leptos will run in, usually either "DEV" or "PROD"
env = "DEV"
# Specify the name of the bin target
bin-target = "libretunes"
# The features to use when compiling the bin target
#
# Optional. Can be over-ridden with the command line parameter --bin-features

21
src/health.rs Normal file
View File

@ -0,0 +1,21 @@
use libretunes::api::health::health;
use server_fn::client::set_server_url;
#[tokio::main]
pub async fn main() {
let host = std::env::args()
.nth(1)
.unwrap_or("http://localhost:3000".to_string());
println!("Runing health check against {host}");
set_server_url(Box::leak(host.into_boxed_str()));
match health().await {
Ok(result) => println!("Health check result: {result:?}"),
Err(err) => {
println!("Error: {err}");
std::process::exit(1);
}
}
}