From b3d9d7d33bc4c7a1d642eebfef46ca963afed31d Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 8 May 2024 10:41:30 +0200 Subject: [PATCH] fix --- src/lib.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 12a0f4a7d..61e8abd13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -160,10 +160,10 @@ pub async fn start_lemmy_server(args: CmdArgs) -> LemmyResult<()> { rate_limit_cell.clone(), ); - if !args.disable_scheduled_tasks { + let scheduled_tasks = (!args.disable_scheduled_tasks).then(|| { // 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() { serve_prometheus(prometheus, context.clone())?; @@ -218,15 +218,17 @@ pub async fn start_lemmy_server(args: CmdArgs) -> LemmyResult<()> { let mut interrupt = tokio::signal::unix::signal(SignalKind::interrupt())?; let mut terminate = tokio::signal::unix::signal(SignalKind::terminate())?; - tokio::select! { - _ = tokio::signal::ctrl_c() => { - tracing::warn!("Received ctrl-c, shutting down gracefully..."); - } - _ = interrupt.recv() => { - tracing::warn!("Received interrupt, shutting down gracefully..."); - } - _ = terminate.recv() => { - tracing::warn!("Received terminate, shutting down gracefully..."); + if server.is_some() || federate.is_some() || scheduled_tasks.is_some() { + tokio::select! { + _ = tokio::signal::ctrl_c() => { + tracing::warn!("Received ctrl-c, shutting down gracefully..."); + } + _ = interrupt.recv() => { + tracing::warn!("Received interrupt, shutting down gracefully..."); + } + _ = terminate.recv() => { + tracing::warn!("Received terminate, shutting down gracefully..."); + } } } if let Some(server) = server {