Compare commits

...
1 Commits
Author SHA1 Message Date
fanyang 30926aec55 feat(cli): support configurable local state directory
Add --state-dir and ET_STATE_DIR for persisted web-client machine IDs.

Fixes #2340
2026-10-09 18:29:50 +08:00
2 changed files with 11 additions and 1 deletions
+3
View File
@@ -13,6 +13,9 @@ core_clap:
the machine id to identify this machine, used for config recovery after disconnection, must be unique and fixed. by default it is loaded from persisted local state; on first start it may be migrated from system information or generated, then remains fixed. the machine id to identify this machine, used for config recovery after disconnection, must be unique and fixed. by default it is loaded from persisted local state; on first start it may be migrated from system information or generated, then remains fixed.
zh-CN: |+ zh-CN: |+
Web 配置服务器通过 machine id 来识别机器,用于断线重连后的配置恢复,需要保证唯一且固定不变。默认从本地持久化状态读取;首次启动时可能基于系统信息迁移或生成,之后保持固定不变。 Web 配置服务器通过 machine id 来识别机器,用于断线重连后的配置恢复,需要保证唯一且固定不变。默认从本地持久化状态读取;首次启动时可能基于系统信息迁移或生成,之后保持固定不变。
state_dir:
en: "directory for persistent local state, currently the Web config server machine ID. Uses the platform default when unset; ignored when --machine-id is specified."
zh-CN: "本地持久化状态目录,目前用于保存 Web 配置服务器的机器 ID。未指定时使用平台默认目录;指定 --machine-id 时不使用此目录。"
config_file: config_file:
en: "path to the config file, NOTE: the options set by cmdline args will override options in config file" en: "path to the config file, NOTE: the options set by cmdline args will override options in config file"
zh-CN: "配置文件路径,注意:命令行中的配置的选项会覆盖配置文件中的选项" zh-CN: "配置文件路径,注意:命令行中的配置的选项会覆盖配置文件中的选项"
+8 -1
View File
@@ -100,6 +100,13 @@ struct Cli {
)] )]
machine_id: Option<String>, machine_id: Option<String>,
#[arg(
long,
env = "ET_STATE_DIR",
help = t!("core_clap.state_dir").to_string()
)]
state_dir: Option<PathBuf>,
#[arg( #[arg(
short, short,
long, long,
@@ -1536,7 +1543,7 @@ async fn run_main(cli: Cli) -> anyhow::Result<()> {
config_server_url_s, config_server_url_s,
crate::common::MachineIdOptions { crate::common::MachineIdOptions {
explicit_machine_id: cli.machine_id.clone(), explicit_machine_id: cli.machine_id.clone(),
state_dir: None, state_dir: cli.state_dir.clone(),
}, },
cli.network_options.hostname.clone(), cli.network_options.hostname.clone(),
cli.network_options.secure_mode.unwrap_or(false), cli.network_options.secure_mode.unwrap_or(false),