aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs
index f38767e..c6fd1d1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,11 +18,19 @@ use log::*;
#[structopt(name = "tricot")]
struct Opt {
/// Address of consul server
- #[structopt(long = "consul-addr", env = "TRICOT_CONSUL_HOST", default_value = "http://127.0.0.1:8500/")]
+ #[structopt(
+ long = "consul-addr",
+ env = "TRICOT_CONSUL_HOST",
+ default_value = "http://127.0.0.1:8500/"
+ )]
pub consul_addr: String,
/// Prefix of Tricot's entries in Consul KV space
- #[structopt(long = "consul-kv-prefix", env = "TRICOT_CONSUL_KV_PREFIX", default_value = "tricot/")]
+ #[structopt(
+ long = "consul-kv-prefix",
+ env = "TRICOT_CONSUL_KV_PREFIX",
+ default_value = "tricot/"
+ )]
pub consul_kv_prefix: String,
/// Node name
@@ -30,15 +38,22 @@ struct Opt {
pub node_name: String,
/// Bind address for HTTP server
- #[structopt(long = "http-bind-addr", env = "TRICOT_HTTP_BIND_ADDR", default_value = "0.0.0.0:80")]
+ #[structopt(
+ long = "http-bind-addr",
+ env = "TRICOT_HTTP_BIND_ADDR",
+ default_value = "0.0.0.0:80"
+ )]
pub http_bind_addr: SocketAddr,
/// Bind address for HTTPS server
- #[structopt(long = "https-bind-addr", env = "TRICOT_HTTPS_BIND_ADDR", default_value = "0.0.0.0:443")]
+ #[structopt(
+ long = "https-bind-addr",
+ env = "TRICOT_HTTPS_BIND_ADDR",
+ default_value = "0.0.0.0:443"
+ )]
pub https_bind_addr: SocketAddr,
}
-
#[tokio::main(flavor = "multi_thread", worker_threads = 10)]
async fn main() {
if std::env::var("RUST_LOG").is_err() {
@@ -53,16 +68,12 @@ async fn main() {
let consul = consul::Consul::new(&opt.consul_addr, &opt.consul_kv_prefix, &opt.node_name);
let mut rx_proxy_config = proxy_config::spawn_proxy_config_task(consul.clone());
- let cert_store = cert_store::CertStore::new(consul.clone());
- tokio::spawn(
- cert_store
- .clone()
- .watch_proxy_config(rx_proxy_config.clone()),
- );
+ let cert_store = cert_store::CertStore::new(consul.clone(), rx_proxy_config.clone());
+ tokio::spawn(cert_store.clone().watch_proxy_config());
tokio::spawn(http::serve_http(opt.http_bind_addr, consul.clone()));
tokio::spawn(https::serve_https(
- opt.https_bind_addr,
+ opt.https_bind_addr,
cert_store.clone(),
rx_proxy_config.clone(),
));