Class: Lemans::Environments::Daytona::Shell
- Inherits:
-
Object
- Object
- Lemans::Environments::Daytona::Shell
- Includes:
- Retries
- Defined in:
- lib/lemans/environments/daytona/shell.rb
Overview
Runs one sandbox's commands. Long commands run detached and are polled — a direct call would die at the HTTP deadline — and no async exit code exists, so the command writes its own.
Constant Summary collapse
- SHORT_COMMAND_SEC =
120- POLL_INTERVAL_SEC =
2- MAX_OUTPUT_BYTES =
200_000- HOUSEKEEPING_TIMEOUT =
60
Constants included from Retries
Retries::READ_ATTEMPTS, Retries::RETRY_DELAY_SEC, Retries::SDK_ERRORS
Instance Method Summary collapse
- #exec(command, timeout: nil, env: {}) ⇒ Object
-
#initialize(sandbox) ⇒ Shell
constructor
A new instance of Shell.
Constructor Details
#initialize(sandbox) ⇒ Shell
Returns a new instance of Shell.
20 21 22 23 24 |
# File 'lib/lemans/environments/daytona/shell.rb', line 20 def initialize(sandbox) @sandbox = sandbox @session_id = fresh_session_id sandbox.process.create_session(@session_id) end |
Instance Method Details
#exec(command, timeout: nil, env: {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lemans/environments/daytona/shell.rb', line 26 def exec(command, timeout: nil, env: {}) validate_env!(env) started = now response = if timeout && timeout > SHORT_COMMAND_SEC exec_in_session(command, timeout: timeout, env: env) else exec_directly(command, timeout: timeout, env: env) end Base::ExecResult.new(command: command, duration_sec: (now - started).round(3), **response) end |