You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New Health CHeck API, but it is not checking anything yet.
You can call it at:
http://localhost:1313/health_check
//! The [`health_check_api::start_job`](crate::bootstrap::jobs::health_check_api::start_job)
4
+
//! function starts the Health Check REST API.
5
+
//!
6
+
//! The [`health_check_api::start_job`](crate::bootstrap::jobs::health_check_api::start_job)
7
+
//! function spawns a new asynchronous task, that tasks is the "**launcher**".
8
+
//! The "**launcher**" starts the actual server and sends a message back
9
+
//! to the main application. The main application waits until receives
10
+
//! the message [`ApiServerJobStarted`]
11
+
//! from the "**launcher**".
12
+
//!
13
+
//! The "**launcher**" is an intermediary thread that decouples the Health Check
14
+
//! API server from the process that handles it.
15
+
//!
16
+
//! Refer to the [configuration documentation](https://docs.rs/torrust-tracker-configuration)
17
+
//! for the API configuration options.
18
+
use std::net::SocketAddr;
19
+
20
+
use log::info;
21
+
use tokio::sync::oneshot;
22
+
use tokio::task::JoinHandle;
23
+
use torrust_tracker_configuration::HealthCheckApi;
24
+
25
+
usecrate::servers::health_check_api::server;
26
+
27
+
/// This is the message that the "launcher" spawned task sends to the main
28
+
/// application process to notify the API server was successfully started.
29
+
///
30
+
/// > **NOTICE**: it does not mean the API server is ready to receive requests.
31
+
/// It only means the new server started. It might take some time to the server
32
+
/// to be ready to accept request.
33
+
#[derive(Debug)]
34
+
pubstructApiServerJobStarted{
35
+
pubbound_addr:SocketAddr,
36
+
}
37
+
38
+
/// This function starts a new Health Check API server with the provided
39
+
/// configuration.
40
+
///
41
+
/// The functions starts a new concurrent task that will run the API server.
42
+
/// This task will send a message to the main application process to notify
43
+
/// that the API server was successfully started.
44
+
///
45
+
/// # Panics
46
+
///
47
+
/// It would panic if unable to send the `ApiServerJobStarted` notice.
info!("Starting Health Check API server: http://{}", bind_addr);
59
+
60
+
let handle = server::start(bind_addr, tx);
61
+
62
+
ifletOk(()) = handle.await{
63
+
info!("Health Check API server on http://{} stopped", bind_addr);
64
+
}
65
+
});
66
+
67
+
// Wait until the API server job is running
68
+
match rx.await{
69
+
Ok(_msg) => info!("Torrust Health Check API server started"),
70
+
Err(e) => panic!("the Health Check API server was dropped: {e}"),
0 commit comments