mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-21 16:05:19 +08:00
feat(cloud): configure dedicated and shared worker quotas independently
This commit is contained in:
@@ -59,6 +59,9 @@ _RUNTIME_POLICY_DEFAULTS = {
|
||||
'restart_failure_window_seconds': 30.0,
|
||||
'restart_circuit_open_seconds': 60.0,
|
||||
'require_hard_limits': False,
|
||||
# Cloud-only optional overrides; null inherits the unified policy.
|
||||
'dedicated': dict.fromkeys(('max_cpus', 'max_memory_mb', 'max_pids', 'max_open_files', 'max_file_size_mb')),
|
||||
'shared': dict.fromkeys(('max_cpus', 'max_memory_mb', 'max_pids', 'max_open_files', 'max_file_size_mb')),
|
||||
},
|
||||
},
|
||||
'mcp': {'stdio': {'enabled': True}},
|
||||
|
||||
@@ -334,6 +334,24 @@ class PluginRuntimeConnector(ManagedRuntimeConnector):
|
||||
):
|
||||
if field_name in PluginWorkerPolicy.model_fields and field_name in worker:
|
||||
policy_data[field_name] = worker.get(field_name)
|
||||
if self.runtime_profile == 'shared':
|
||||
for mode in ('dedicated', 'shared'):
|
||||
overrides = worker.get(mode)
|
||||
if isinstance(overrides, dict):
|
||||
overrides = dict(overrides)
|
||||
for name, value in overrides.items():
|
||||
# Optional leaves start as null, so env loading preserves
|
||||
# strings. Parse only these trusted numeric config fields.
|
||||
if isinstance(value, str) and name in (
|
||||
'max_cpus',
|
||||
'max_memory_mb',
|
||||
'max_pids',
|
||||
'max_open_files',
|
||||
'max_file_size_mb',
|
||||
):
|
||||
overrides[name] = float(value) if name == 'max_cpus' else int(value)
|
||||
if overrides is not None:
|
||||
policy_data[mode] = overrides
|
||||
return PluginWorkerPolicy.model_validate(policy_data)
|
||||
|
||||
def _control_headers(self, *, allow_generate: bool) -> dict[str, str]:
|
||||
|
||||
Reference in New Issue
Block a user