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
45
46
47
48
49
50
51
52
|
// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective
// SPDX-License-Identifier: GPL-3.0-only
use crate::{
api::Api,
config::Config,
prompt::Prompt,
server::{
distributor::Distributor,
hub::Hub,
Server,
ServerType::{AutoServer, RoomServer},
},
};
pub async fn run() {
let (tx, _rx) = std::sync::mpsc::channel();
let _threads = vec![
tokio::spawn(async move {
let _ = Distributor::listen(
&*format!("0.0.0.0:{}", Config::get().distributor.port),
AutoServer,
)
.await;
}),
tokio::spawn(async move {
let _ = Hub::listen(&*format!("0.0.0.0:{}", Config::get().hub.port), RoomServer).await;
}),
tokio::spawn(async move {
let _ = Api::listen(
tx,
&*format!("0.0.0.0:{}", Config::get().whirlsplash.api.port),
)
.await;
}),
];
if std::env::var("DISABLE_PROMPT").unwrap_or_else(|_| "false".to_string()) == "true"
|| !Config::get().whirlsplash.prompt.enable
{
info!("starting with prompt disabled");
loop {
std::thread::sleep(std::time::Duration::default());
}
} else {
// std::thread::sleep(std::time::Duration::from_secs(2));
Prompt::handle().await;
}
// actix_web::rt::System::new("").block_on(rx.recv().unwrap().stop(true));
}
|