From 524abb213faec04c31a1a2b48e966f32aea5cf06 Mon Sep 17 00:00:00 2001 From: Gun9niR Date: Thu, 2 Feb 2023 05:43:13 +0000 Subject: [PATCH 1/2] cli fallback to env --- src/compute/src/lib.rs | 26 +++++++++++++------------- src/frontend/src/lib.rs | 16 ++++++++-------- src/meta/src/lib.rs | 28 ++++++++++++++-------------- src/storage/compactor/src/lib.rs | 20 ++++++++++---------- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/compute/src/lib.rs b/src/compute/src/lib.rs index 74b9048f5f4bf..f41e425a5b59c 100644 --- a/src/compute/src/lib.rs +++ b/src/compute/src/lib.rs @@ -38,37 +38,37 @@ use risingwave_common_proc_macro::OverrideConfig; #[derive(Parser, Clone, Debug)] pub struct ComputeNodeOpts { // TODO: rename to listen_address and separate out the port. - #[clap(long, default_value = "127.0.0.1:5688")] + #[clap(long, env, default_value = "127.0.0.1:5688")] pub host: String, /// The address of the compute node's meta client. /// /// Optional, we will use listen_address if not specified. - #[clap(long)] + #[clap(long, env)] pub client_address: Option, - #[clap(long, default_value = "127.0.0.1:1222")] + #[clap(long, env, default_value = "127.0.0.1:1222")] pub prometheus_listener_addr: String, - #[clap(long, default_value = "http://127.0.0.1:5690")] + #[clap(long, env, default_value = "http://127.0.0.1:5690")] pub meta_address: String, /// Endpoint of the connector node - #[clap(long, env = "CONNECTOR_RPC_ENDPOINT")] + #[clap(long, env)] pub connector_rpc_endpoint: Option, /// The path of `risingwave.toml` configuration file. /// /// If empty, default configuration values will be used. - #[clap(long, default_value = "")] + #[clap(long, env, default_value = "")] pub config_path: String, /// Total available memory in bytes, used by LRU Manager - #[clap(long, default_value_t = default_total_memory_bytes())] + #[clap(long, env, default_value_t = default_total_memory_bytes())] pub total_memory_bytes: usize, /// The parallelism that the compute node will register to the scheduler of the meta service. - #[clap(long, default_value_t = default_parallelism())] + #[clap(long, env, default_value_t = default_parallelism())] pub parallelism: usize, #[clap(flatten)] @@ -84,30 +84,30 @@ struct OverrideConfigOpts { /// `memory` or `memory-shared`. /// 2. `in-memory` /// 3. `sled://{path}` - #[clap(long)] + #[clap(long, env)] #[override_opts(path = storage.state_store)] pub state_store: Option, /// Used for control the metrics level, similar to log level. /// 0 = close metrics /// >0 = open metrics - #[clap(long)] + #[clap(long, env)] #[override_opts(path = server.metrics_level)] pub metrics_level: Option, /// Path to file cache data directory. /// Left empty to disable file cache. - #[clap(long)] + #[clap(long, env)] #[override_opts(path = storage.file_cache.dir)] pub file_cache_dir: Option, /// Enable reporting tracing information to jaeger. - #[clap(parse(from_flag = true_if_present), long)] + #[clap(parse(from_flag = true_if_present), long, env)] #[override_opts(path = streaming.enable_jaeger_tracing)] pub enable_jaeger_tracing: Flag, /// Enable async stack tracing for risectl. - #[clap(long, arg_enum)] + #[clap(long, env, arg_enum)] #[override_opts(path = streaming.async_stack_trace)] pub async_stack_trace: Option, } diff --git a/src/frontend/src/lib.rs b/src/frontend/src/lib.rs index 6b5d18153078e..803415f526761 100644 --- a/src/frontend/src/lib.rs +++ b/src/frontend/src/lib.rs @@ -70,24 +70,24 @@ use session::SessionManagerImpl; #[derive(Parser, Clone, Debug)] pub struct FrontendOpts { // TODO: rename to listen_address and separate out the port. - #[clap(long, default_value = "127.0.0.1:4566")] + #[clap(long, env, default_value = "127.0.0.1:4566")] pub host: String, // Optional, we will use listen_address if not specified. - #[clap(long)] + #[clap(long, env)] pub client_address: Option, // TODO: This is currently unused. - #[clap(long)] + #[clap(long, env)] pub port: Option, - #[clap(long, default_value = "http://127.0.0.1:5690")] + #[clap(long, env, default_value = "http://127.0.0.1:5690")] pub meta_addr: String, - #[clap(long, default_value = "127.0.0.1:2222")] + #[clap(long, env, default_value = "127.0.0.1:2222")] pub prometheus_listener_addr: String, - #[clap(long, default_value = "127.0.0.1:6786")] + #[clap(long, env, default_value = "127.0.0.1:6786")] pub health_check_listener_addr: String, /// The path of `risingwave.toml` configuration file. @@ -96,7 +96,7 @@ pub struct FrontendOpts { /// /// Note that internal system parameters should be defined in the configuration file at /// [`risingwave_common::config`] instead of command line arguments. - #[clap(long, default_value = "")] + #[clap(long, env, default_value = "")] pub config_path: String, #[clap(flatten)] @@ -109,7 +109,7 @@ struct OverrideConfigOpts { /// Used for control the metrics level, similar to log level. /// 0 = close metrics /// >0 = open metrics - #[clap(long)] + #[clap(long, env)] #[override_opts(path = server.metrics_level)] pub metrics_level: Option, } diff --git a/src/meta/src/lib.rs b/src/meta/src/lib.rs index 07fdfe5a2d8f5..15c873aee17ef 100644 --- a/src/meta/src/lib.rs +++ b/src/meta/src/lib.rs @@ -58,57 +58,57 @@ use crate::rpc::server::{rpc_serve, AddressInfo, MetaStoreBackend}; #[derive(Debug, Clone, Parser)] pub struct MetaNodeOpts { // TODO: rename to listen_address and separate out the port. - #[clap(long, default_value = "127.0.0.1:5690")] + #[clap(long, env, default_value = "127.0.0.1:5690")] listen_addr: String, /// Deprecated. But we keep it for backward compatibility. - #[clap(long)] + #[clap(long, env)] host: Option, /// The endpoint for this meta node, which also serves as its unique identifier in cluster /// membership and leader election. - #[clap(long)] + #[clap(long, env)] meta_endpoint: Option, - #[clap(long)] + #[clap(long, env)] dashboard_host: Option, - #[clap(long)] + #[clap(long, env)] prometheus_host: Option, - #[clap(long, default_value_t = String::from(""))] + #[clap(long, env, default_value_t = String::from(""))] etcd_endpoints: String, /// Enable authentication with etcd. By default disabled. - #[clap(long)] + #[clap(long, env)] etcd_auth: bool, /// Username of etcd, required when --etcd-auth is enabled. /// Default value is read from the 'ETCD_USERNAME' environment variable. - #[clap(long, env = "ETCD_USERNAME", default_value = "")] + #[clap(long, env, default_value = "")] etcd_username: String, /// Password of etcd, required when --etcd-auth is enabled. /// Default value is read from the 'ETCD_PASSWORD' environment variable. - #[clap(long, env = "ETCD_PASSWORD", default_value = "")] + #[clap(long, env, default_value = "")] etcd_password: String, - #[clap(long)] + #[clap(long, env)] dashboard_ui_path: Option, /// For dashboard service to fetch cluster info. - #[clap(long)] + #[clap(long, env)] prometheus_endpoint: Option, /// Endpoint of the connector node, there will be a sidecar connector node /// colocated with Meta node in the cloud environment - #[clap(long, env = "META_CONNECTOR_RPC_ENDPOINT")] + #[clap(long, env)] pub connector_rpc_endpoint: Option, /// The path of `risingwave.toml` configuration file. /// /// If empty, default configuration values will be used. - #[clap(long, default_value = "")] + #[clap(long, env, default_value = "")] pub config_path: String, #[clap(flatten)] @@ -118,7 +118,7 @@ pub struct MetaNodeOpts { /// Command-line arguments for compute-node that overrides the config file. #[derive(Parser, Clone, Debug, OverrideConfig)] pub struct OverrideConfigOpts { - #[clap(long, arg_enum)] + #[clap(long, env, arg_enum)] #[override_opts(path = meta.backend)] backend: Option, } diff --git a/src/storage/compactor/src/lib.rs b/src/storage/compactor/src/lib.rs index 119c73fb39c17..eb550b43294aa 100644 --- a/src/storage/compactor/src/lib.rs +++ b/src/storage/compactor/src/lib.rs @@ -25,30 +25,30 @@ use crate::server::compactor_serve; #[derive(Parser, Clone, Debug)] pub struct CompactorOpts { // TODO: rename to listen_address and separate out the port. - #[clap(long, default_value = "127.0.0.1:6660")] + #[clap(long, env, default_value = "127.0.0.1:6660")] pub host: String, // Optional, we will use listen_address if not specified. - #[clap(long)] + #[clap(long, env)] pub client_address: Option, // TODO: This is currently unused. - #[clap(long)] + #[clap(long, env)] pub port: Option, - #[clap(long, default_value = "127.0.0.1:1260")] + #[clap(long, env, default_value = "127.0.0.1:1260")] pub prometheus_listener_addr: String, - #[clap(long, default_value = "http://127.0.0.1:5690")] + #[clap(long, env, default_value = "http://127.0.0.1:5690")] pub meta_address: String, - #[clap(long)] + #[clap(long, env)] pub compaction_worker_threads_number: Option, /// The path of `risingwave.toml` configuration file. /// /// If empty, default configuration values will be used. - #[clap(long, default_value = "")] + #[clap(long, env, default_value = "")] pub config_path: String, #[clap(flatten)] @@ -61,19 +61,19 @@ struct OverrideConfigOpts { /// Of the form `hummock+{object_store}` where `object_store` /// is one of `s3://{path}`, `s3-compatible://{path}`, `minio://{path}`, `disk://{path}`, /// `memory` or `memory-shared`. - #[clap(long)] + #[clap(long, env)] #[override_opts(path = storage.state_store)] pub state_store: Option, /// Used for control the metrics level, similar to log level. /// 0 = close metrics /// >0 = open metrics - #[clap(long)] + #[clap(long, env)] #[override_opts(path = server.metrics_level)] pub metrics_level: Option, /// It's a hint used by meta node. - #[clap(long)] + #[clap(long, env)] #[override_opts(path = storage.max_concurrent_compaction_task_number)] pub max_concurrent_task_number: Option, } From 5bf3412cbd435a119d0a8a565bf70a117311e688 Mon Sep 17 00:00:00 2001 From: Gun9niR Date: Thu, 2 Feb 2023 07:45:42 +0000 Subject: [PATCH 2/2] use RW prefix --- src/compute/src/lib.rs | 30 +++++++++++++++++------------- src/frontend/src/lib.rs | 24 ++++++++++++++++-------- src/meta/src/lib.rs | 30 ++++++++++++++---------------- src/storage/compactor/src/lib.rs | 24 ++++++++++++++---------- 4 files changed, 61 insertions(+), 47 deletions(-) diff --git a/src/compute/src/lib.rs b/src/compute/src/lib.rs index f41e425a5b59c..6a9cf8407be62 100644 --- a/src/compute/src/lib.rs +++ b/src/compute/src/lib.rs @@ -38,37 +38,41 @@ use risingwave_common_proc_macro::OverrideConfig; #[derive(Parser, Clone, Debug)] pub struct ComputeNodeOpts { // TODO: rename to listen_address and separate out the port. - #[clap(long, env, default_value = "127.0.0.1:5688")] + #[clap(long, env = "RW_HOST", default_value = "127.0.0.1:5688")] pub host: String, /// The address of the compute node's meta client. /// /// Optional, we will use listen_address if not specified. - #[clap(long, env)] + #[clap(long, env = "RW_CLIENT_ADDRESS")] pub client_address: Option, - #[clap(long, env, default_value = "127.0.0.1:1222")] + #[clap( + long, + env = "RW_PROMETHEUS_LISTENER_ADDR", + default_value = "127.0.0.1:1222" + )] pub prometheus_listener_addr: String, - #[clap(long, env, default_value = "http://127.0.0.1:5690")] + #[clap(long, env = "RW_META_ADDRESS", default_value = "http://127.0.0.1:5690")] pub meta_address: String, /// Endpoint of the connector node - #[clap(long, env)] + #[clap(long, env = "RW_CONNECTOR_RPC_ENDPOINT")] pub connector_rpc_endpoint: Option, /// The path of `risingwave.toml` configuration file. /// /// If empty, default configuration values will be used. - #[clap(long, env, default_value = "")] + #[clap(long, env = "RW_CONFIG_PATH", default_value = "")] pub config_path: String, /// Total available memory in bytes, used by LRU Manager - #[clap(long, env, default_value_t = default_total_memory_bytes())] + #[clap(long, env = "RW_TOTAL_MEMORY_BYTES", default_value_t = default_total_memory_bytes())] pub total_memory_bytes: usize, /// The parallelism that the compute node will register to the scheduler of the meta service. - #[clap(long, env, default_value_t = default_parallelism())] + #[clap(long, env = "RW_PARALLELISM", default_value_t = default_parallelism())] pub parallelism: usize, #[clap(flatten)] @@ -84,30 +88,30 @@ struct OverrideConfigOpts { /// `memory` or `memory-shared`. /// 2. `in-memory` /// 3. `sled://{path}` - #[clap(long, env)] + #[clap(long, env = "RW_STATE_STORE")] #[override_opts(path = storage.state_store)] pub state_store: Option, /// Used for control the metrics level, similar to log level. /// 0 = close metrics /// >0 = open metrics - #[clap(long, env)] + #[clap(long, env = "RW_METRICS_LEVEL")] #[override_opts(path = server.metrics_level)] pub metrics_level: Option, /// Path to file cache data directory. /// Left empty to disable file cache. - #[clap(long, env)] + #[clap(long, env = "RW_FILE_CACHE_DIR")] #[override_opts(path = storage.file_cache.dir)] pub file_cache_dir: Option, /// Enable reporting tracing information to jaeger. - #[clap(parse(from_flag = true_if_present), long, env)] + #[clap(long, env = "RW_ENABLE_JAEGER_TRACING", parse(from_flag = true_if_present))] #[override_opts(path = streaming.enable_jaeger_tracing)] pub enable_jaeger_tracing: Flag, /// Enable async stack tracing for risectl. - #[clap(long, env, arg_enum)] + #[clap(long, env = "RW_ASYNC_STACK_TRACE", arg_enum)] #[override_opts(path = streaming.async_stack_trace)] pub async_stack_trace: Option, } diff --git a/src/frontend/src/lib.rs b/src/frontend/src/lib.rs index 803415f526761..3e81c49d77dea 100644 --- a/src/frontend/src/lib.rs +++ b/src/frontend/src/lib.rs @@ -70,24 +70,32 @@ use session::SessionManagerImpl; #[derive(Parser, Clone, Debug)] pub struct FrontendOpts { // TODO: rename to listen_address and separate out the port. - #[clap(long, env, default_value = "127.0.0.1:4566")] + #[clap(long, env = "RW_HOST", default_value = "127.0.0.1:4566")] pub host: String, // Optional, we will use listen_address if not specified. - #[clap(long, env)] + #[clap(long, env = "RW_CLIENT_ADDRESS")] pub client_address: Option, // TODO: This is currently unused. - #[clap(long, env)] + #[clap(long, env = "RW_PORT")] pub port: Option, - #[clap(long, env, default_value = "http://127.0.0.1:5690")] + #[clap(long, env = "RW_META_ADDR", default_value = "http://127.0.0.1:5690")] pub meta_addr: String, - #[clap(long, env, default_value = "127.0.0.1:2222")] + #[clap( + long, + env = "RW_PROMETHEUS_LISTENER_ADDR", + default_value = "127.0.0.1:2222" + )] pub prometheus_listener_addr: String, - #[clap(long, env, default_value = "127.0.0.1:6786")] + #[clap( + long, + env = "RW_HEALTH_CHECK_LISTENER_ADDR", + default_value = "127.0.0.1:6786" + )] pub health_check_listener_addr: String, /// The path of `risingwave.toml` configuration file. @@ -96,7 +104,7 @@ pub struct FrontendOpts { /// /// Note that internal system parameters should be defined in the configuration file at /// [`risingwave_common::config`] instead of command line arguments. - #[clap(long, env, default_value = "")] + #[clap(long, env = "RW_CONFIG_PATH", default_value = "")] pub config_path: String, #[clap(flatten)] @@ -109,7 +117,7 @@ struct OverrideConfigOpts { /// Used for control the metrics level, similar to log level. /// 0 = close metrics /// >0 = open metrics - #[clap(long, env)] + #[clap(long, env = "RW_METRICS_LEVEL")] #[override_opts(path = server.metrics_level)] pub metrics_level: Option, } diff --git a/src/meta/src/lib.rs b/src/meta/src/lib.rs index 15c873aee17ef..c9f97cb0b47d4 100644 --- a/src/meta/src/lib.rs +++ b/src/meta/src/lib.rs @@ -58,57 +58,55 @@ use crate::rpc::server::{rpc_serve, AddressInfo, MetaStoreBackend}; #[derive(Debug, Clone, Parser)] pub struct MetaNodeOpts { // TODO: rename to listen_address and separate out the port. - #[clap(long, env, default_value = "127.0.0.1:5690")] + #[clap(long, env = "RW_LISTEN_ADDR", default_value = "127.0.0.1:5690")] listen_addr: String, /// Deprecated. But we keep it for backward compatibility. - #[clap(long, env)] + #[clap(long, env = "RW_HOST")] host: Option, /// The endpoint for this meta node, which also serves as its unique identifier in cluster /// membership and leader election. - #[clap(long, env)] + #[clap(long, env = "RW_META_ENDPOINT")] meta_endpoint: Option, - #[clap(long, env)] + #[clap(long, env = "RW_DASHBOARD_HOST")] dashboard_host: Option, - #[clap(long, env)] + #[clap(long, env = "RW_PROMETHEUS_HOST")] prometheus_host: Option, - #[clap(long, env, default_value_t = String::from(""))] + #[clap(long, env = "RW_ETCD_ENDPOINTS", default_value_t = String::from(""))] etcd_endpoints: String, /// Enable authentication with etcd. By default disabled. - #[clap(long, env)] + #[clap(long, env = "RW_ETCD_AUTH")] etcd_auth: bool, /// Username of etcd, required when --etcd-auth is enabled. - /// Default value is read from the 'ETCD_USERNAME' environment variable. - #[clap(long, env, default_value = "")] + #[clap(long, env = "RW_ETCD_USERNAME", default_value = "")] etcd_username: String, /// Password of etcd, required when --etcd-auth is enabled. - /// Default value is read from the 'ETCD_PASSWORD' environment variable. - #[clap(long, env, default_value = "")] + #[clap(long, env = "RW_ETCD_PASSWORD", default_value = "")] etcd_password: String, - #[clap(long, env)] + #[clap(long, env = "RW_DASHBOARD_UI_PATH")] dashboard_ui_path: Option, /// For dashboard service to fetch cluster info. - #[clap(long, env)] + #[clap(long, env = "RW_PROMETHEUS_ENDPOINT")] prometheus_endpoint: Option, /// Endpoint of the connector node, there will be a sidecar connector node /// colocated with Meta node in the cloud environment - #[clap(long, env)] + #[clap(long, env = "RW_CONNECTOR_RPC_ENDPOINT")] pub connector_rpc_endpoint: Option, /// The path of `risingwave.toml` configuration file. /// /// If empty, default configuration values will be used. - #[clap(long, env, default_value = "")] + #[clap(long, env = "RW_CONFIG_PATH", default_value = "RW_CONFIG_PATH")] pub config_path: String, #[clap(flatten)] @@ -118,7 +116,7 @@ pub struct MetaNodeOpts { /// Command-line arguments for compute-node that overrides the config file. #[derive(Parser, Clone, Debug, OverrideConfig)] pub struct OverrideConfigOpts { - #[clap(long, env, arg_enum)] + #[clap(long, env = "RW_BACKEND", arg_enum)] #[override_opts(path = meta.backend)] backend: Option, } diff --git a/src/storage/compactor/src/lib.rs b/src/storage/compactor/src/lib.rs index eb550b43294aa..7c34518c80296 100644 --- a/src/storage/compactor/src/lib.rs +++ b/src/storage/compactor/src/lib.rs @@ -25,30 +25,34 @@ use crate::server::compactor_serve; #[derive(Parser, Clone, Debug)] pub struct CompactorOpts { // TODO: rename to listen_address and separate out the port. - #[clap(long, env, default_value = "127.0.0.1:6660")] + #[clap(long, env = "RW_HOST", default_value = "127.0.0.1:6660")] pub host: String, // Optional, we will use listen_address if not specified. - #[clap(long, env)] + #[clap(long, env = "RW_CLIENT_ADDRESS")] pub client_address: Option, // TODO: This is currently unused. - #[clap(long, env)] + #[clap(long, env = "RW_PORT")] pub port: Option, - #[clap(long, env, default_value = "127.0.0.1:1260")] + #[clap( + long, + env = "RW_PROMETHEUS_LISTENER_ADDR", + default_value = "127.0.0.1:1260" + )] pub prometheus_listener_addr: String, - #[clap(long, env, default_value = "http://127.0.0.1:5690")] + #[clap(long, env = "RW_META_ADDRESS", default_value = "http://127.0.0.1:5690")] pub meta_address: String, - #[clap(long, env)] + #[clap(long, env = "RW_COMPACTION_WORKER_THREADS_NUMBER")] pub compaction_worker_threads_number: Option, /// The path of `risingwave.toml` configuration file. /// /// If empty, default configuration values will be used. - #[clap(long, env, default_value = "")] + #[clap(long, env = "RW_CONFIG_PATH", default_value = "")] pub config_path: String, #[clap(flatten)] @@ -61,19 +65,19 @@ struct OverrideConfigOpts { /// Of the form `hummock+{object_store}` where `object_store` /// is one of `s3://{path}`, `s3-compatible://{path}`, `minio://{path}`, `disk://{path}`, /// `memory` or `memory-shared`. - #[clap(long, env)] + #[clap(long, env = "RW_STATE_STORE")] #[override_opts(path = storage.state_store)] pub state_store: Option, /// Used for control the metrics level, similar to log level. /// 0 = close metrics /// >0 = open metrics - #[clap(long, env)] + #[clap(long, env = "RW_METRICS_LEVEL")] #[override_opts(path = server.metrics_level)] pub metrics_level: Option, /// It's a hint used by meta node. - #[clap(long, env)] + #[clap(long, env = "RW_MAX_CONCURRENT_TASK_NUMBER")] #[override_opts(path = storage.max_concurrent_compaction_task_number)] pub max_concurrent_task_number: Option, }