Add some fixes and debug stuff
This commit is contained in:
parent
45e128361a
commit
3b00001859
3 changed files with 27 additions and 3 deletions
emgauwa-controller/src
|
@ -27,16 +27,30 @@ async fn run_relays(app_state: &Addr<AppState>) -> Result<(), EmgauwaError> {
|
|||
let default_duration = Duration::new(10, 0);
|
||||
let notifier = &*app_state_get_notifier(app_state).await?;
|
||||
|
||||
let mut this = utils::app_state_get_this(app_state).await?;
|
||||
|
||||
loop {
|
||||
let notifier_future = notifier.notified();
|
||||
pin_mut!(notifier_future);
|
||||
let timeout_result = timeout(default_duration, &mut notifier_future).await;
|
||||
let changed = timeout_result.is_ok();
|
||||
|
||||
if changed {
|
||||
log::debug!("Reloading controller in relay loop");
|
||||
this = utils::app_state_get_this(app_state).await?;
|
||||
}
|
||||
|
||||
let mut relay_debug = String::new();
|
||||
for relay in this.relays.iter() {
|
||||
relay_debug.push_str(&format!(
|
||||
"{}: {} |",
|
||||
relay.r.name, relay.active_schedule.name
|
||||
));
|
||||
}
|
||||
log::debug!(
|
||||
"Relay loop at {} (changed: {})",
|
||||
"Relay loop at {}: {}",
|
||||
Local::now().naive_local().time(),
|
||||
changed
|
||||
relay_debug
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue