Fix scheduler

This commit is contained in:
2022-10-01 13:11:07 +06:00
parent 5b45b75982
commit bce3d035df
2 changed files with 3 additions and 3 deletions

View File

@@ -52,7 +52,7 @@ async fn main() {
tokio::spawn(async { tokio::spawn(async {
match cron_jobs().await { match cron_jobs().await {
Ok(_) => (), Ok(v) => v.await,
Err(e) => panic!("{:?}", e), Err(e) => panic!("{:?}", e),
} }
}); });

View File

@@ -501,7 +501,7 @@ pub async fn update() -> Result<(), Box<dyn std::error::Error>> {
Ok(()) Ok(())
} }
pub async fn cron_jobs() -> Result<(), JobSchedulerError> { pub async fn cron_jobs() -> Result<tokio::task::JoinHandle<()>, JobSchedulerError> {
let job_scheduler = JobScheduler::new().await.unwrap(); let job_scheduler = JobScheduler::new().await.unwrap();
let update_job = match Job::new_async("0 0 5 * * *", |_uuid, _l| Box::pin(async { let update_job = match Job::new_async("0 0 5 * * *", |_uuid, _l| Box::pin(async {
@@ -517,7 +517,7 @@ pub async fn cron_jobs() -> Result<(), JobSchedulerError> {
job_scheduler.add(update_job).await.unwrap(); job_scheduler.add(update_job).await.unwrap();
match job_scheduler.start().await { match job_scheduler.start().await {
Ok(_) => Ok(()), Ok(v) => Ok(v),
Err(err) => Err(err), Err(err) => Err(err),
} }
} }