feat: remove shutdown message because it doesn't hit
This commit is contained in:
parent
710e3eeb94
commit
6be649f0fc
2 changed files with 0 additions and 41 deletions
|
|
@ -83,24 +83,4 @@ impl DiscordClient {
|
||||||
info!("Discord startup message sent successfully in {:?}", duration);
|
info!("Discord startup message sent successfully in {:?}", duration);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_shutdown_message(&self) -> Result<()> {
|
|
||||||
let start = Instant::now();
|
|
||||||
info!("Sending Discord shutdown message");
|
|
||||||
|
|
||||||
let embed = CreateEmbed::new()
|
|
||||||
.title("Noisebell is shutting down")
|
|
||||||
.description("The Noisebell service is stopping. Status updates won't go through")
|
|
||||||
.color(Color::new(0x800080)) // Purple for shutdown
|
|
||||||
.thumbnail("https://static.vecteezy.com/system/resources/thumbnails/050/619/685/large/a-laptop-computer-on-fire-on-a-desk-in-a-dark-room-video.jpg");
|
|
||||||
|
|
||||||
if let Err(why) = self.channel_id.send_message(&self.client.http, CreateMessage::default().add_embed(embed)).await {
|
|
||||||
error!("Error sending Discord shutdown message: {:?}", why);
|
|
||||||
return Err(anyhow::anyhow!("Failed to send Discord shutdown message: {}", why));
|
|
||||||
}
|
|
||||||
|
|
||||||
let duration = start.elapsed();
|
|
||||||
info!("Discord shutdown message sent successfully in {:?}", duration);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
21
src/main.rs
21
src/main.rs
|
|
@ -11,22 +11,6 @@ use tracing_appender::rolling::{RollingFileAppender, Rotation};
|
||||||
use tracing_subscriber::filter::LevelFilter;
|
use tracing_subscriber::filter::LevelFilter;
|
||||||
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
|
|
||||||
struct ShutdownGuard {
|
|
||||||
discord_client: Arc<discord::DiscordClient>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for ShutdownGuard {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
info!("Shutdown guard triggered");
|
|
||||||
let runtime = tokio::runtime::Runtime::new().unwrap();
|
|
||||||
runtime.block_on(async {
|
|
||||||
if let Err(e) = self.discord_client.send_shutdown_message().await {
|
|
||||||
error!("Failed to send shutdown message: {}", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
info!("creating logs directory");
|
info!("creating logs directory");
|
||||||
|
|
@ -58,11 +42,6 @@ async fn main() -> Result<()> {
|
||||||
let discord_client = discord::DiscordClient::new().await?;
|
let discord_client = discord::DiscordClient::new().await?;
|
||||||
let discord_client = Arc::new(discord_client);
|
let discord_client = Arc::new(discord_client);
|
||||||
|
|
||||||
// Create shutdown guard that will send message on any exit
|
|
||||||
let _guard = ShutdownGuard {
|
|
||||||
discord_client: Arc::clone(&discord_client),
|
|
||||||
};
|
|
||||||
|
|
||||||
discord_client.send_startup_message().await?;
|
discord_client.send_startup_message().await?;
|
||||||
|
|
||||||
const DEFAULT_GPIO_PIN: u8 = 17;
|
const DEFAULT_GPIO_PIN: u8 = 17;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue