fix: 🚑 run rustler immediately when no rules configured
This commit is contained in:
parent
1e3fa72077
commit
8a8f47a859
@ -159,10 +159,10 @@ where
|
||||
rustler.set_msg_sender(Some(sender))
|
||||
}
|
||||
|
||||
if let Some((start, stop)) = rules {
|
||||
let start_name = format!("start-rustler-{}", market.short_name);
|
||||
let end_name = format!("end-rustler-{}", market.short_name);
|
||||
|
||||
if let Some((start, stop)) = &rules {
|
||||
// TODO: we will need to store the job handlers in the `RustlersSvc` struct
|
||||
// so that we can stop them when we need to restart the rustlers
|
||||
|
||||
@ -194,17 +194,16 @@ where
|
||||
market.short_name,
|
||||
end_job.get_next_run()
|
||||
);
|
||||
} else {
|
||||
info!("No schedule rules found for market '{}'", market.short_name);
|
||||
}
|
||||
|
||||
if should_be_running_now(start, stop) {
|
||||
if should_be_running_now(rules) {
|
||||
info!("Starting '{start_name}' right away");
|
||||
Self::start_rustler_for(rustler.clone(), tickers).await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
warn!("No schedule rules found for market '{}'", market.short_name);
|
||||
Ok(())
|
||||
}
|
||||
} else {
|
||||
warn!("No rustler found for market '{}'", market.short_name);
|
||||
Ok(())
|
||||
@ -314,7 +313,8 @@ enum Op {
|
||||
}
|
||||
|
||||
/// checks if the rustler should be running now
|
||||
fn should_be_running_now(start: SchedulingRule, stop: SchedulingRule) -> bool {
|
||||
fn should_be_running_now(rules: Option<(SchedulingRule, SchedulingRule)>) -> bool {
|
||||
if let Some((start, stop)) = rules {
|
||||
let now = chrono::Local::now();
|
||||
|
||||
let start_date = start.next_from(now);
|
||||
@ -330,4 +330,8 @@ fn should_be_running_now(start: SchedulingRule, stop: SchedulingRule) -> bool {
|
||||
(Some(start), Some(stop)) => stop < start && now < stop,
|
||||
_ => true,
|
||||
}
|
||||
} else {
|
||||
// if there are no rules, it means the rustler should be running all the time
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user