mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Add pause_closed_runtimes config to pause instead of stop runtimes (#6885)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
parent
6ba79c454b
commit
ef62ccde36
@ -41,6 +41,7 @@ class SandboxConfig(BaseModel):
|
||||
remote_runtime_api_url: str | None = Field(default='http://localhost:8000')
|
||||
local_runtime_url: str = Field(default='http://localhost')
|
||||
keep_runtime_alive: bool = Field(default=False)
|
||||
pause_closed_runtimes: bool = Field(default=True)
|
||||
rm_all_containers: bool = Field(default=False)
|
||||
api_key: str | None = Field(default=None)
|
||||
base_container_image: str = Field(
|
||||
|
||||
@ -377,7 +377,22 @@ class RemoteRuntime(ActionExecutionClient):
|
||||
raise AgentRuntimeNotReadyError()
|
||||
|
||||
def close(self):
|
||||
if self.config.sandbox.keep_runtime_alive or self.attach_to_existing:
|
||||
if self.attach_to_existing:
|
||||
super().close()
|
||||
return
|
||||
if self.config.sandbox.keep_runtime_alive:
|
||||
if self.config.sandbox.pause_closed_runtimes:
|
||||
try:
|
||||
if not self._runtime_closed:
|
||||
with self._send_runtime_api_request(
|
||||
'POST',
|
||||
f'{self.config.sandbox.remote_runtime_api_url}/pause',
|
||||
json={'runtime_id': self.runtime_id},
|
||||
):
|
||||
self.log('debug', 'Runtime paused.')
|
||||
except Exception as e:
|
||||
self.log('error', f'Unable to pause runtime: {str(e)}')
|
||||
raise e
|
||||
super().close()
|
||||
return
|
||||
try:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user