|
@@ -429,6 +429,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
} else {
|
|
} else {
|
|
|
Some(internal_token.clone())
|
|
Some(internal_token.clone())
|
|
|
};
|
|
};
|
|
|
|
|
+ // 持久化路径可被 `KLT_BOS_INSTANCE_ID_PATH` 覆盖(本机联调写 temp/runtime;
|
|
|
|
|
+ // 云端/容器未设时仍落 `/var/lib/seoh/...`,⛔ 在源码里写死本机路径)。
|
|
|
|
|
+ let instance_id_path = std::env::var("KLT_BOS_INSTANCE_ID_PATH").unwrap_or_else(|_| {
|
|
|
|
|
+ "/var/lib/seoh/klt-bos-instance-id.json".to_string()
|
|
|
|
|
+ });
|
|
|
let mut reg_config = seoh_service_sdk::build_registry_registration_config_from_env(
|
|
let mut reg_config = seoh_service_sdk::build_registry_registration_config_from_env(
|
|
|
&cfg.registry.url,
|
|
&cfg.registry.url,
|
|
|
&cfg.registry.service_name,
|
|
&cfg.registry.service_name,
|
|
@@ -438,7 +443,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
adv_port,
|
|
adv_port,
|
|
|
cfg.server.tls_enabled,
|
|
cfg.server.tls_enabled,
|
|
|
cfg.registry.signature_secret.as_deref(),
|
|
cfg.registry.signature_secret.as_deref(),
|
|
|
- "/var/lib/seoh/klt-bos-instance-id.json",
|
|
|
|
|
|
|
+ &instance_id_path,
|
|
|
runtime_token_for_registry,
|
|
runtime_token_for_registry,
|
|
|
);
|
|
);
|
|
|
// ⚠️ `build_registry_registration_config_from_env` 固定产出 `tls_config: None`,
|
|
// ⚠️ `build_registry_registration_config_from_env` 固定产出 `tls_config: None`,
|
|
@@ -548,7 +553,11 @@ async fn deregister_from_registry(
|
|
|
.instance_id_persistence
|
|
.instance_id_persistence
|
|
|
.as_ref()
|
|
.as_ref()
|
|
|
.map(|p| p.file_path.clone())
|
|
.map(|p| p.file_path.clone())
|
|
|
- .unwrap_or_else(|| "/var/lib/seoh/klt-bos-instance-id.json".to_string());
|
|
|
|
|
|
|
+ .unwrap_or_else(|| {
|
|
|
|
|
+ std::env::var("KLT_BOS_INSTANCE_ID_PATH").unwrap_or_else(|_| {
|
|
|
|
|
+ "/var/lib/seoh/klt-bos-instance-id.json".to_string()
|
|
|
|
|
+ })
|
|
|
|
|
+ });
|
|
|
let instance_id = match std::fs::read_to_string(&persist_path) {
|
|
let instance_id = match std::fs::read_to_string(&persist_path) {
|
|
|
Ok(s) => match serde_json::from_str::<serde_json::Value>(&s) {
|
|
Ok(s) => match serde_json::from_str::<serde_json::Value>(&s) {
|
|
|
Ok(v) => v
|
|
Ok(v) => v
|