diff options
author | Alex Auvolat <alex@adnab.me> | 2021-12-07 17:56:15 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-12-07 17:56:15 +0100 |
commit | 0682c74e9d5083b43b3f83f8bb1ca747658d1455 (patch) | |
tree | 6532eba8bf707c9d32bdbc6535ccc082e2229096 /src/main.rs | |
parent | bb77e7c459a624bb2b4ea043145fd6ea75771105 (diff) | |
download | tricot-0682c74e9d5083b43b3f83f8bb1ca747658d1455.tar.gz tricot-0682c74e9d5083b43b3f83f8bb1ca747658d1455.zip |
Watch multiple consul nodes
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 9d710b2..4a0c0ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,8 @@ #[macro_use] extern crate anyhow; +use structopt::StructOpt; + mod cert; mod cert_store; mod consul; @@ -11,15 +13,34 @@ mod reverse_proxy; use log::*; +#[derive(StructOpt, Debug)] +#[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/")] + 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/")] + pub consul_kv_prefix: String, + + /// Node name + #[structopt(long = "node-name", env = "TRICOT_NODE_NAME", default_value = "<none>")] + pub node_name: String, +} + #[tokio::main(flavor = "multi_thread", worker_threads = 10)] async fn main() { if std::env::var("RUST_LOG").is_err() { std::env::set_var("RUST_LOG", "tricot=debug") } pretty_env_logger::init(); + + let opt = Opt::from_args(); + info!("Starting Tricot"); - let consul = consul::Consul::new("http://10.42.0.21:8500", "tricot/", "carcajou"); + 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()); |