periodically print shard info
This commit is contained in:
parent
8db0a05785
commit
6f86f2afa0
25
src/main.rs
25
src/main.rs
@ -8,7 +8,7 @@ mod framework;
|
|||||||
mod guild_data;
|
mod guild_data;
|
||||||
mod sound;
|
mod sound;
|
||||||
|
|
||||||
use std::{collections::HashMap, env, sync::Arc};
|
use std::{collections::HashMap, env, sync::Arc, time::Duration};
|
||||||
|
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
@ -310,6 +310,29 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|||||||
|
|
||||||
framework_arc.build_slash(&client.cache_and_http.http).await;
|
framework_arc.build_slash(&client.cache_and_http.http).await;
|
||||||
|
|
||||||
|
let shard_manager = client.shard_manager.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
loop {
|
||||||
|
{
|
||||||
|
let mut shards = shard_manager
|
||||||
|
.lock()
|
||||||
|
.await
|
||||||
|
.runners
|
||||||
|
.lock()
|
||||||
|
.await
|
||||||
|
.iter()
|
||||||
|
.map(|(id, shard)| format!("\t{} {}", id.0, shard.stage))
|
||||||
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
|
shards.sort();
|
||||||
|
|
||||||
|
info!("Shard Status: [\n{}\n]", shards.join("\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
tokio::time::sleep(Duration::from_secs(60)).await;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if let Ok((Some(lower), Some(upper))) = env::var("SHARD_RANGE").map(|sr| {
|
if let Ok((Some(lower), Some(upper))) = env::var("SHARD_RANGE").map(|sr| {
|
||||||
let mut split = sr
|
let mut split = sr
|
||||||
.split(',')
|
.split(',')
|
||||||
|
Loading…
Reference in New Issue
Block a user