graceful shutdown

This commit is contained in:
jude
2022-03-21 23:11:52 +00:00
parent 93da746bdc
commit 878ea11502
9 changed files with 189 additions and 74 deletions

View File

@ -9,7 +9,7 @@ mod routes;
use std::{collections::HashMap, env};
use oauth2::{basic::BasicClient, AuthUrl, ClientId, ClientSecret, RedirectUrl, TokenUrl};
use rocket::fs::FileServer;
use rocket::{fs::FileServer, tokio::sync::broadcast::Sender};
use rocket_dyn_templates::Template;
use serenity::{
client::Context,
@ -53,6 +53,7 @@ async fn internal_server_error() -> Template {
}
pub async fn initialize(
kill_channel: Sender<()>,
serenity_context: Context,
db_pool: Pool<Database>,
) -> Result<(), Box<dyn std::error::Error>> {
@ -119,6 +120,10 @@ pub async fn initialize(
.launch()
.await?;
warn!("Exiting rocket runtime");
// distribute kill signal
kill_channel.send(());
Ok(())
}