2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 19:31:35 +00:00

Gate cleanup behind read-only config

This commit is contained in:
asonix 2023-07-22 20:26:28 -05:00
parent 13d6e10886
commit 7dc8ede8eb

View file

@ -1344,10 +1344,14 @@ fn configure_endpoints<
); );
} }
fn spawn_cleanup<R>(repo: R) fn spawn_cleanup<R>(repo: R, config: &Configuration)
where where
R: FullRepo + 'static, R: FullRepo + 'static,
{ {
if config.server.read_only {
return;
}
tracing::trace_span!(parent: None, "Spawn task").in_scope(|| { tracing::trace_span!(parent: None, "Spawn task").in_scope(|| {
actix_rt::spawn(async move { actix_rt::spawn(async move {
let mut interval = actix_rt::time::interval(Duration::from_secs(30)); let mut interval = actix_rt::time::interval(Duration::from_secs(30));
@ -1404,7 +1408,7 @@ async fn launch_file_store<R: FullRepo + 'static, F: Fn(&mut web::ServiceConfig)
let address = config.server.address; let address = config.server.address;
spawn_cleanup(repo.clone()); spawn_cleanup(repo.clone(), &config);
HttpServer::new(move || { HttpServer::new(move || {
let client = client.clone(); let client = client.clone();
@ -1446,7 +1450,7 @@ async fn launch_object_store<
let address = config.server.address; let address = config.server.address;
spawn_cleanup(repo.clone()); spawn_cleanup(repo.clone(), &config);
HttpServer::new(move || { HttpServer::new(move || {
let client = client.clone(); let client = client.clone();