feat(cli): support configurable local state directory (#2654)

Add --state-dir and ET_STATE_DIR for persisted web-client machine IDs.

Fixes #2340
This commit is contained in:
fanyang authored and GitHub committed 2026-10-09 21:23:02 +08:00
1 parent 7af7bdc16a
commit 7fdfe90291
2 files changed
+11 -1

No files matched your search

+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.
zh-CN: |+
Web 配置服务器通过 machine id 来识别机器,用于断线重连后的配置恢复,需要保证唯一且固定不变。默认从本地持久化状态读取;首次启动时可能基于系统信息迁移或生成,之后保持固定不变。
state_dir:
en: "directory for persistent local state, currently used for 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:
en: "path to the config file, NOTE: the options set by cmdline args will override options in config file"
zh-CN: "配置文件路径,注意:命令行中的配置的选项会覆盖配置文件中的选项"
+8 -1
View File
@@ -100,6 +100,13 @@ struct Cli {
)]
machine_id: Option<String>,
#[arg(
long,
env = "ET_STATE_DIR",
help = t!("core_clap.state_dir").to_string()
)]
state_dir: Option<PathBuf>,
#[arg(
short,
long,
@@ -1536,7 +1543,7 @@ async fn run_main(cli: Cli) -> anyhow::Result<()> {
config_server_url_s,
crate::common::MachineIdOptions {
explicit_machine_id: cli.machine_id.clone(),
state_dir: None,
state_dir: cli.state_dir.clone(),
},
cli.network_options.hostname.clone(),
cli.network_options.secure_mode.unwrap_or(false),