This commit is contained in:
Mateusz Gruszczyński committed 2026-10-19 11:09:48 +02:00
1 parent 4afa88a65e
commit 2ab44c4c62
49 files changed
+1523 -176

No files matched your search

+15
View File
@@ -2,6 +2,7 @@ async fn run(
data_dir: PathBuf,
startup_admin_addr: SocketAddr,
options: ServeOptions,
file_config: Option<PathBuf>,
startup_locks: rust_proxy::settings::StartupLocks,
update_check: rust_proxy::update_check::Config,
) -> Result<()> {
@@ -74,7 +75,15 @@ async fn run(
};
let store = Store::open(&data_dir.join("config.sqlite3"), &initial).await?;
let mut saved = store.load().await?;
let external = if let Some(path) = file_config {
Some((path.clone(), rust_proxy::runtime::external_config::read(&path)?))
} else { None };
let saved_revision = saved.revision;
let stored_document = serde_json::to_value(&saved.config)?;
if let Some((_, (config, _))) = &external { saved.config = config.clone(); }
startup_locks.ensure_config(&mut saved.config);
let changed_on_disk = external.is_some() && serde_json::to_value(&saved.config)? != stored_document;
if changed_on_disk { saved.revision = saved.revision.checked_add(1).context("revision overflow")?; }
startup_locks
.validate(&saved.config, startup_admin_addr)
.context("stored configuration conflicts with a listener fixed by systemd/startup")?;
@@ -129,6 +138,10 @@ async fn run(
})
.await?
.context("stored configuration is invalid; no automatic reset was performed")?;
if changed_on_disk {
ensure!(store.replace_as(saved_revision, &snapshot.envelope.config, "file-startup").await?,
"configuration history changed while loading --config");
}
rust_proxy::logging::configure_error_log(snapshot.envelope.config.error_log.clone());
let admin_tls_config = {
let tls = snapshot.envelope.config.tls.clone();
@@ -166,6 +179,8 @@ async fn run(
startup_locks,
geoip,
);
if let Some((path, (_, hash))) = external { state.set_config_file(path, hash).await; }
state.prometheus_token_hash.store(store.prometheus_token_hash().await?.map(Arc::new));
state.acme.restore_renewals(renewal_observations);
// Bind EVERY listener before spawning servers: a missing private IP or
// occupied port fails startup atomically, never falling back to 0.0.0.0.