From cb471c52f39f8dc7f23c2b8acb281edc32355537 Mon Sep 17 00:00:00 2001 From: jude Date: Sat, 19 Feb 2022 12:45:33 +0000 Subject: [PATCH] optionally dont run web/postman --- src/main.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index fbff421..2530322 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,7 @@ use std::{ use chrono_tz::Tz; use dotenv::dotenv; -use log::info; +use log::{info, warn}; use serenity::{ async_trait, client::Client, @@ -88,13 +88,23 @@ impl EventHandler for Handler { let pool1 = ctx1.data.read().await.get::().cloned().unwrap(); let pool2 = ctx2.data.read().await.get::().cloned().unwrap(); - tokio::spawn(async move { - postman::initialize(ctx1, &pool1).await; - }); + let run_settings = env::var("DONTRUN").unwrap_or_else(|_| "".to_string()); - tokio::spawn(async move { - reminder_web::initialize(ctx2, pool2).await.unwrap(); - }); + if !run_settings.contains("postman") { + tokio::spawn(async move { + postman::initialize(ctx1, &pool1).await; + }); + } else { + warn!("Not running postman") + } + + if !run_settings.contains("web") { + tokio::spawn(async move { + reminder_web::initialize(ctx2, pool2).await.unwrap(); + }); + } else { + warn!("Not running web") + } self.is_loop_running.swap(true, Ordering::Relaxed); }