2021-12-06 22:08:22 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate anyhow;
|
|
|
|
|
2021-12-07 12:50:44 +00:00
|
|
|
mod cert;
|
|
|
|
mod cert_store;
|
2021-12-06 22:08:22 +00:00
|
|
|
mod consul;
|
2021-12-07 12:50:44 +00:00
|
|
|
mod http;
|
2021-12-06 22:08:22 +00:00
|
|
|
mod proxy_config;
|
|
|
|
|
|
|
|
use log::*;
|
|
|
|
|
2021-12-07 12:50:44 +00:00
|
|
|
#[tokio::main(flavor = "multi_thread")]
|
2021-12-06 22:08:22 +00:00
|
|
|
async fn main() {
|
2021-12-07 12:50:44 +00:00
|
|
|
if std::env::var("RUST_LOG").is_err() {
|
|
|
|
std::env::set_var("RUST_LOG", "tricot=debug")
|
|
|
|
}
|
2021-12-06 22:08:22 +00:00
|
|
|
pretty_env_logger::init();
|
|
|
|
info!("Starting Tricot");
|
|
|
|
|
2021-12-06 22:40:41 +00:00
|
|
|
let consul = consul::Consul::new("http://10.42.0.21:8500", "tricot/");
|
2021-12-06 22:08:22 +00:00
|
|
|
let mut rx_proxy_config = proxy_config::spawn_proxy_config_task(consul.clone(), "carcajou");
|
|
|
|
|
2021-12-07 12:50:44 +00:00
|
|
|
let cert_store = cert_store::CertStore::new(consul.clone());
|
|
|
|
tokio::spawn(
|
|
|
|
cert_store
|
|
|
|
.clone()
|
|
|
|
.watch_proxy_config(rx_proxy_config.clone()),
|
|
|
|
);
|
|
|
|
|
|
|
|
tokio::spawn(http::serve_http(consul.clone()));
|
2021-12-06 22:40:41 +00:00
|
|
|
|
2021-12-06 22:08:22 +00:00
|
|
|
while rx_proxy_config.changed().await.is_ok() {
|
|
|
|
info!("Proxy config: {:#?}", *rx_proxy_config.borrow());
|
|
|
|
}
|
|
|
|
}
|