This commit is contained in:
Felix Ableitner 2024-05-08 10:41:30 +02:00
parent 870a0043c4
commit b3d9d7d33b

View File

@ -160,10 +160,10 @@ pub async fn start_lemmy_server(args: CmdArgs) -> LemmyResult<()> {
rate_limit_cell.clone(), rate_limit_cell.clone(),
); );
if !args.disable_scheduled_tasks { let scheduled_tasks = (!args.disable_scheduled_tasks).then(|| {
// Schedules various cleanup tasks for the DB // Schedules various cleanup tasks for the DB
let _scheduled_tasks = tokio::task::spawn(scheduled_tasks::setup(context.clone())); tokio::task::spawn(scheduled_tasks::setup(context.clone()))
} });
if let Some(prometheus) = SETTINGS.prometheus.clone() { if let Some(prometheus) = SETTINGS.prometheus.clone() {
serve_prometheus(prometheus, context.clone())?; serve_prometheus(prometheus, context.clone())?;
@ -218,6 +218,7 @@ pub async fn start_lemmy_server(args: CmdArgs) -> LemmyResult<()> {
let mut interrupt = tokio::signal::unix::signal(SignalKind::interrupt())?; let mut interrupt = tokio::signal::unix::signal(SignalKind::interrupt())?;
let mut terminate = tokio::signal::unix::signal(SignalKind::terminate())?; let mut terminate = tokio::signal::unix::signal(SignalKind::terminate())?;
if server.is_some() || federate.is_some() || scheduled_tasks.is_some() {
tokio::select! { tokio::select! {
_ = tokio::signal::ctrl_c() => { _ = tokio::signal::ctrl_c() => {
tracing::warn!("Received ctrl-c, shutting down gracefully..."); tracing::warn!("Received ctrl-c, shutting down gracefully...");
@ -229,6 +230,7 @@ pub async fn start_lemmy_server(args: CmdArgs) -> LemmyResult<()> {
tracing::warn!("Received terminate, shutting down gracefully..."); tracing::warn!("Received terminate, shutting down gracefully...");
} }
} }
}
if let Some(server) = server { if let Some(server) = server {
server.stop(true).await; server.stop(true).await;
} }