add delay before starting updates check
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
7d6710c033
commit
89a158ab0b
1 changed files with 9 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use conduit::{debug, info, warn, Result};
|
use conduit::{debug, info, warn, Result, Server};
|
||||||
use database::{Deserialized, Map};
|
use database::{Deserialized, Map};
|
||||||
use ruma::events::room::message::RoomMessageEventContent;
|
use ruma::events::room::message::RoomMessageEventContent;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
@ -23,6 +23,7 @@ struct Services {
|
||||||
admin: Dep<admin::Service>,
|
admin: Dep<admin::Service>,
|
||||||
client: Dep<client::Service>,
|
client: Dep<client::Service>,
|
||||||
globals: Dep<globals::Service>,
|
globals: Dep<globals::Service>,
|
||||||
|
server: Arc<Server>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
@ -52,11 +53,12 @@ impl crate::Service for Service {
|
||||||
globals: args.depend::<globals::Service>("globals"),
|
globals: args.depend::<globals::Service>("globals"),
|
||||||
admin: args.depend::<admin::Service>("admin"),
|
admin: args.depend::<admin::Service>("admin"),
|
||||||
client: args.depend::<client::Service>("client"),
|
client: args.depend::<client::Service>("client"),
|
||||||
|
server: args.server.clone(),
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all, name = "updates", level = "trace")]
|
#[tracing::instrument(skip_all, name = "updates", level = "debug")]
|
||||||
async fn worker(self: Arc<Self>) -> Result<()> {
|
async fn worker(self: Arc<Self>) -> Result<()> {
|
||||||
if !self.services.globals.allow_check_for_updates() {
|
if !self.services.globals.allow_check_for_updates() {
|
||||||
debug!("Disabling update check");
|
debug!("Disabling update check");
|
||||||
|
@ -65,6 +67,7 @@ impl crate::Service for Service {
|
||||||
|
|
||||||
let mut i = interval(self.interval);
|
let mut i = interval(self.interval);
|
||||||
i.set_missed_tick_behavior(MissedTickBehavior::Delay);
|
i.set_missed_tick_behavior(MissedTickBehavior::Delay);
|
||||||
|
i.reset_after(self.interval);
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
() = self.interrupt.notified() => break,
|
() = self.interrupt.notified() => break,
|
||||||
|
@ -85,8 +88,10 @@ impl crate::Service for Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
#[tracing::instrument(skip_all, level = "trace")]
|
#[tracing::instrument(skip_all)]
|
||||||
async fn check(&self) -> Result<()> {
|
async fn check(&self) -> Result<()> {
|
||||||
|
debug_assert!(self.services.server.running(), "server must not be shutting down");
|
||||||
|
|
||||||
let response = self
|
let response = self
|
||||||
.services
|
.services
|
||||||
.client
|
.client
|
||||||
|
@ -108,6 +113,7 @@ impl Service {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
async fn handle(&self, update: &CheckForUpdatesResponseEntry) {
|
async fn handle(&self, update: &CheckForUpdatesResponseEntry) {
|
||||||
info!("{} {:#}", update.date, update.message);
|
info!("{} {:#}", update.date, update.message);
|
||||||
self.services
|
self.services
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue