Compare commits

...

2 Commits

Author SHA1 Message Date
03073965a1 Merge pull request 'use recommended method of 'sleep'' (#470) from show-waterlevel into staging
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m52s
CI/CD Pipeline / deploy-staging (push) Successful in 6m20s
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #470
2024-04-30 15:56:47 +02:00
2189b082c0 use recommended method of 'sleep'
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m34s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-04-30 15:56:21 +02:00

View File

@ -3,7 +3,7 @@ mod waterlevel;
use std::time::Duration; use std::time::Duration;
use job_scheduler_ng::{Job, JobScheduler}; use job_scheduler_ng::{Job, JobScheduler};
use rocket::tokio::{self, task}; use rocket::tokio::{self, task, time};
use sqlx::SqlitePool; use sqlx::SqlitePool;
pub fn schedule(db: &SqlitePool) { pub fn schedule(db: &SqlitePool) {
@ -26,9 +26,10 @@ pub fn schedule(db: &SqlitePool) {
}); });
})); }));
let mut interval = time::interval(Duration::from_secs(60));
loop { loop {
sched.tick(); sched.tick();
std::thread::sleep(Duration::from_secs(60)); interval.tick().await;
} }
}); });
} }