Fetcher: separate init() from start() [start may rerun everytime we go online]

This commit is contained in:
Mike Dilger 2024-03-14 12:31:12 +13:00
parent 3e882b7416
commit 5eb9d46187
2 changed files with 11 additions and 4 deletions

View File

@ -47,7 +47,7 @@ impl Fetcher {
}
}
pub(crate) fn start() -> Result<(), Error> {
pub(crate) fn init() -> Result<(), Error> {
// Setup the cache directory
*GLOBALS.fetcher.cache_dir.write().unwrap() = Profile::current()?.cache_dir;
@ -68,6 +68,10 @@ impl Fetcher {
.build()?,
);
Ok(())
}
pub(crate) fn start() {
// Setup periodic queue management
let fetcher_looptime_ms = GLOBALS.storage.read_setting_fetcher_looptime_ms();
tokio::task::spawn(async move {
@ -83,9 +87,9 @@ impl Fetcher {
break;
}
}
});
Ok(())
tracing::info!("Fetcher shutdown");
});
}
/// Count of HTTP requests queued for future fetching

View File

@ -186,8 +186,11 @@ impl Overlord {
.feed
.set_feed_starts(general_feed_start, person_feed_start, inbox_feed_start);
// Init the fetcher
crate::fetcher::Fetcher::init()?;
// Start the fetcher
crate::fetcher::Fetcher::start()?;
crate::fetcher::Fetcher::start();
// Start periodic tasks in people manager (after signer)
crate::people::People::start();