forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rs
More file actions
44 lines (37 loc) · 1.11 KB
/
main.rs
File metadata and controls
44 lines (37 loc) · 1.11 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
use std::sync::Arc;
use log::info;
use torrust_tracker::Configuration;
use torrust_tracker::logging;
use torrust_tracker::setup;
use torrust_tracker::tracker::tracker::TorrentTracker;
#[tokio::main]
async fn main() {
const CONFIG_PATH: &str = "config.toml";
// Initialize Torrust config
let config = match Configuration::load_from_file(CONFIG_PATH) {
Ok(config) => Arc::new(config),
Err(error) => {
panic!("{}", error)
}
};
// Initialize Torrust tracker
let tracker = match TorrentTracker::new(config.clone()) {
Ok(tracker) => Arc::new(tracker),
Err(error) => {
panic!("{}", error)
}
};
// Initialize logging
logging::setup_logging(&config);
// Run jobs
let jobs = setup::setup(&config, tracker.clone()).await;
// handle the signals here
tokio::select! {
_ = tokio::signal::ctrl_c() => {
info!("Torrust shutting down..");
// Await for all jobs to shutdown
futures::future::join_all(jobs).await;
info!("Torrust successfully shutdown.");
}
}
}