Skip to content

Commit 583aa2c

Browse files
Pigbibiclaude
andauthored
fix(config): add monitor targets auto-sync for LongBridge (#248)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 84422ac commit 583aa2c

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

main.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,29 @@ def _normalize_plugin_mounts_strategy(raw_mounts_json: str | None) -> str | None
105105
if normalized != RUNTIME_SETTINGS.strategy_plugin_mounts_json:
106106
object.__setattr__(RUNTIME_SETTINGS, "strategy_plugin_mounts_json", normalized)
107107

108+
for _env_name in ("MONITOR_DISPATCH_TARGETS_JSON", "LONGBRIDGE_MONITOR_DISPATCH_TARGETS_JSON"):
109+
_raw = os.environ.get(_env_name)
110+
if _raw:
111+
try:
112+
_targets = json.loads(_raw)
113+
except json.JSONDecodeError:
114+
continue
115+
if not isinstance(_targets, dict):
116+
continue
117+
_entries = _targets.get("targets")
118+
if not isinstance(_entries, list):
119+
continue
120+
_changed = False
121+
for _entry in _entries:
122+
if isinstance(_entry, dict):
123+
_old = _entry.get("strategy_profile")
124+
if _old and _old != STRATEGY_PROFILE:
125+
_entry["strategy_profile"] = STRATEGY_PROFILE
126+
_changed = True
127+
print(f"[config-sync] {_env_name} strategy_profile corrected: {_old}{STRATEGY_PROFILE}", flush=True)
128+
if _changed:
129+
os.environ[_env_name] = json.dumps(_targets, ensure_ascii=False)
130+
108131
ACCOUNT_REGION = RUNTIME_SETTINGS.account_region
109132
MARKET = RUNTIME_SETTINGS.market
110133
MARKET_CALENDAR = RUNTIME_SETTINGS.market_calendar

0 commit comments

Comments
 (0)