Skip to content

Commit

Permalink
Merge torrust#608: Add timeout to http_health_check binary
Browse files Browse the repository at this point in the history
3e2b152 feat: [torrust#604] add timeout to http_health_check binary (Jose Celano)

Pull request description:

  Add timeout to `http_health_check` binary.

ACKs for top commit:
  josecelano:
    ACK 3e2b152

Tree-SHA512: e0a49c32f0cd8888ae3229f4c43e2cca307e9d7fb99a3336c4d6a5f3a4068accabce0497378bbfd66e8dc3ee4db95fd1a0c52b1aff3bafacd0548f6e6daba3f5
  • Loading branch information
josecelano committed Jan 16, 2024
2 parents 1d9d4f3 + 3e2b152 commit b001ffd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/bin/http_health_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
//!
//! - They are harder to maintain.
//! - They introduce new attack vectors.
use std::time::Duration;
use std::{env, process};

use reqwest::Client;

#[tokio::main]
async fn main() {
let args: Vec<String> = env::args().collect();
Expand All @@ -19,7 +22,9 @@ async fn main() {

let url = &args[1].clone();

match reqwest::get(url).await {
let client = Client::builder().timeout(Duration::from_secs(5)).build().unwrap();

match client.get(url).send().await {
Ok(response) => {
if response.status().is_success() {
println!("STATUS: {}", response.status());
Expand Down

0 comments on commit b001ffd

Please sign in to comment.