MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / start_certbot_task

Function start_certbot_task

gateway/src/main_service.rs:525–554  ·  view source on GitHub ↗

Start periodic certificate renewal task for multi-domain certbot

(proxy: Proxy)

Source from the content-addressed store, hash-verified

523
524/// Start periodic certificate renewal task for multi-domain certbot
525async fn start_certbot_task(proxy: Proxy) {
526 info!("starting certificate renewal task");
527
528 // Periodic renewal task for all domains
529 tokio::spawn(async move {
530 // Run once at startup to check for any pending renewals
531 info!("running initial certificate renewal check");
532 if let Err(err) = proxy.renew_cert(None, false).await {
533 error!("failed initial certificate renewal: {err:?}");
534 }
535
536 loop {
537 // Get current config from KV store (allows dynamic updates)
538 let renew_interval = proxy.kv_store.get_certbot_config().renew_interval;
539 if renew_interval.is_zero() {
540 // Check again later if disabled
541 tokio::time::sleep(Duration::from_secs(60)).await;
542 continue;
543 }
544
545 // Wait for the interval
546 tokio::time::sleep(renew_interval).await;
547
548 // Renew certificates
549 if let Err(err) = proxy.renew_cert(None, false).await {
550 error!("failed to renew certificates: {err:?}");
551 }
552 }
553 });
554}
555
556/// Watch for certificate changes from KvStore and update CertStore
557fn start_cert_store_watch_task(proxy: Proxy) {

Callers 1

start_bg_tasksMethod · 0.85

Calls 2

renew_certMethod · 0.45
get_certbot_configMethod · 0.45

Tested by

no test coverage detected