Skip to content

Commit 717e3ff

Browse files
authored
feat(l2): enviroment variables option for "l2 init" command (#2488)
**Motivation** devops **Description** add the following enviroment variables to customize the l2 init command. Specially useful for systemd or docker services ``` ETHREX_NETWORK ETHREX_DATADIR ETHREX_METRICS_PORT ETHREX_EVM ETHREX_HTTP_ADDR ETHREX_HTTP_PORT ```
1 parent ac268f1 commit 717e3ff

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

cmd/ethrex/cli.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ pub struct Options {
3737
value_name = "GENESIS_FILE_PATH",
3838
help = "Receives a `Genesis` struct in json format. This is the only argument which is required. You can look at some example genesis files at `test_data/genesis*`.",
3939
long_help = "Alternatively, the name of a known network can be provided instead to use its preset genesis file and include its preset bootnodes. The networks currently supported include holesky, sepolia, hoodi and mainnet.",
40-
help_heading = "Node options"
40+
help_heading = "Node options",
41+
env = "ETHREX_NETWORK"
4142
)]
4243
pub network: Option<String>,
4344
#[arg(long = "bootnodes", value_parser = clap::value_parser!(Node), value_name = "BOOTNODE_LIST", value_delimiter = ',', num_args = 1.., help = "Comma separated enode URLs for P2P discovery bootstrap.", help_heading = "P2P options")]
@@ -49,7 +50,8 @@ pub struct Options {
4950
default_value = DEFAULT_DATADIR,
5051
help = "Receives the name of the directory where the Database is located.",
5152
long_help = "If the datadir is the word `memory`, ethrex will use the `InMemory Engine`.",
52-
help_heading = "Node options"
53+
help_heading = "Node options",
54+
env = "ETHREX_DATADIR"
5355
)]
5456
pub datadir: String,
5557
#[arg(
@@ -73,7 +75,8 @@ pub struct Options {
7375
long = "metrics.port",
7476
value_name = "PROMETHEUS_METRICS_PORT",
7577
default_value = "9090", // Default Prometheus port (https://prometheus.io/docs/tutorials/getting_started/#show-me-how-it-is-done).
76-
help_heading = "Node options"
78+
help_heading = "Node options",
79+
env = "ETHREX_METRICS_PORT"
7780
)]
7881
pub metrics_port: String,
7982
#[arg(
@@ -90,25 +93,33 @@ pub struct Options {
9093
value_name = "EVM_BACKEND",
9194
help = "Has to be `levm` or `revm`",
9295
value_parser = utils::parse_evm_engine,
93-
help_heading = "Node options"
94-
)]
96+
help_heading = "Node options",
97+
env = "ETHREX_EVM")]
9598
pub evm: EvmEngine,
96-
#[arg(long = "log.level", default_value_t = Level::INFO, value_name = "LOG_LEVEL", help = "The verbosity level used for logs.", long_help = "Possible values: info, debug, trace, warn, error",help_heading = "Node options")]
99+
#[arg(
100+
long = "log.level",
101+
default_value_t = Level::INFO,
102+
value_name = "LOG_LEVEL",
103+
help = "The verbosity level used for logs.",
104+
long_help = "Possible values: info, debug, trace, warn, error",
105+
help_heading = "Node options")]
97106
pub log_level: Level,
98107
#[arg(
99108
long = "http.addr",
100109
default_value = "localhost",
101110
value_name = "ADDRESS",
102111
help = "Listening address for the http rpc server.",
103-
help_heading = "RPC options"
112+
help_heading = "RPC options",
113+
env = "ETHREX_HTTP_ADDR"
104114
)]
105115
pub http_addr: String,
106116
#[arg(
107117
long = "http.port",
108118
default_value = "8545",
109119
value_name = "PORT",
110120
help = "Listening port for the http rpc server.",
111-
help_heading = "RPC options"
121+
help_heading = "RPC options",
122+
env = "ETHREX_HTTP_PORT"
112123
)]
113124
pub http_port: String,
114125
#[arg(

0 commit comments

Comments
 (0)