Class: OpenSandbox::Execd::Commands

Inherits:
Object
  • Object
show all
Defined in:
lib/open_sandbox/execd/commands.rb

Defined Under Namespace

Classes: CommandResult

Instance Method Summary collapse

Constructor Details

#initialize(execd) ⇒ Commands

Returns a new instance of Commands.



8
9
10
# File 'lib/open_sandbox/execd/commands.rb', line 8

def initialize(execd)
  @execd = execd
end

Instance Method Details

#run(command, timeout: 60) ⇒ Object

Run a shell command and wait for completion. The execd API returns SSE-formatted response.



14
15
16
17
18
19
20
21
# File 'lib/open_sandbox/execd/commands.rb', line 14

def run(command, timeout: 60)
  response = @execd.proxy(
    method: :post,
    path: "/command",
    body: { command: command, timeout: timeout, background: false }
  )
  parse_sse_response(response.body)
end