forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.rs
More file actions
32 lines (26 loc) · 932 Bytes
/
Copy pathserver.rs
File metadata and controls
32 lines (26 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::net::SocketAddr;
use std::sync::Arc;
use warp::serve;
use super::routes::routes;
use crate::tracker;
pub fn start(socket_addr: SocketAddr, tracker: &Arc<tracker::Tracker>) -> impl warp::Future<Output = ()> {
let (_addr, api_server) = serve(routes(tracker)).bind_with_graceful_shutdown(socket_addr, async move {
tokio::signal::ctrl_c().await.expect("Failed to listen to shutdown signal.");
});
api_server
}
pub fn start_tls(
socket_addr: SocketAddr,
ssl_cert_path: String,
ssl_key_path: String,
tracker: &Arc<tracker::Tracker>,
) -> impl warp::Future<Output = ()> {
let (_addr, api_server) = serve(routes(tracker))
.tls()
.cert_path(ssl_cert_path)
.key_path(ssl_key_path)
.bind_with_graceful_shutdown(socket_addr, async move {
tokio::signal::ctrl_c().await.expect("Failed to listen to shutdown signal.");
});
api_server
}