Create health check bin
This commit is contained in:
13
Cargo.toml
13
Cargo.toml
@ -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
21
src/health.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user