mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
feat: support instance_id in system config
Add instance_id field to system section in config.yaml. Can be set via SYSTEM__INSTANCE_ID env var (auto-mapped). Falls back to data/labels/instance_id.json if not set.
This commit is contained in:
@@ -146,6 +146,8 @@ class LoadConfigStage(stage.BootingStage):
|
||||
await ap.instance_config.dump_config()
|
||||
|
||||
# load or generate instance id
|
||||
# Priority: system.instance_id from config.yaml (can be set via env var
|
||||
# SYSTEM__INSTANCE_ID which is auto-mapped) > data/labels/instance_id.json > generate new
|
||||
ap.instance_id = await config.load_json_config(
|
||||
'data/labels/instance_id.json',
|
||||
template_data={
|
||||
@@ -155,7 +157,13 @@ class LoadConfigStage(stage.BootingStage):
|
||||
completion=False,
|
||||
)
|
||||
|
||||
constants.instance_id = ap.instance_id.data['instance_id']
|
||||
config_instance_id = ap.instance_config.data.get('system', {}).get('instance_id', '')
|
||||
if config_instance_id:
|
||||
# Use the instance_id from config.yaml (e.g. injected via SYSTEM__INSTANCE_ID env var)
|
||||
constants.instance_id = config_instance_id
|
||||
else:
|
||||
# Fall back to the file-based instance id
|
||||
constants.instance_id = ap.instance_id.data['instance_id']
|
||||
constants.edition = ap.instance_config.data.get('system', {}).get('edition', 'community')
|
||||
|
||||
print(f'LangBot instance id: {constants.instance_id}')
|
||||
|
||||
@@ -16,6 +16,7 @@ proxy:
|
||||
http: ''
|
||||
https: ''
|
||||
system:
|
||||
instance_id: ''
|
||||
edition: community
|
||||
recovery_key: ''
|
||||
allow_modify_login_info: true
|
||||
|
||||
Reference in New Issue
Block a user