fix: bug for dynamic reloading of config files

This commit is contained in:
Jun Kurihara 2023-08-09 14:07:40 +09:00
commit 7c2205f275
No known key found for this signature in database
GPG key ID: D992B3E3DE1DED23
5 changed files with 44 additions and 12 deletions

View file

@ -84,7 +84,7 @@ async fn rpxy_service_without_watcher(
return Err(anyhow::anyhow!(e));
}
};
entrypoint(&proxy_conf, &app_conf, &runtime_handle)
entrypoint(&proxy_conf, &app_conf, &runtime_handle, None)
.await
.map_err(|e| anyhow::anyhow!(e))
}
@ -105,10 +105,13 @@ async fn rpxy_service_with_watcher(
}
};
// Notifier for proxy service termination
let term_notify = std::sync::Arc::new(tokio::sync::Notify::new());
// Continuous monitoring
loop {
tokio::select! {
_ = entrypoint(&proxy_conf, &app_conf, &runtime_handle) => {
_ = entrypoint(&proxy_conf, &app_conf, &runtime_handle, Some(term_notify.clone())) => {
error!("rpxy entrypoint exited");
break;
}
@ -127,7 +130,9 @@ async fn rpxy_service_with_watcher(
continue;
}
};
info!("Configuration updated. Force to re-bind TCP/UDP sockets");
info!("Configuration updated. Terminate all spawned proxy services and force to re-bind TCP/UDP sockets");
term_notify.notify_waiters();
// tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
}
else => break
}