Miosa.Sandbox.Processes (Miosa v1.1.0)

Copy Markdown View Source

Background process management for a sandbox.

Wraps:

  • POST /sandboxes/:id/processes — start/4
  • GET /sandboxes/:id/processes — list/2
  • DELETE /sandboxes/:id/processes/:pid — kill/3
  • POST /sandboxes/:id/processes/:pid/stdin — send_stdin/4

Summary

Functions

Get a single process by PID (GET /sandboxes/:sandbox_id/processes/:pid).

Alias for stop/3 (kept for backwards-compat).

List all running background processes in the sandbox (GET /sandboxes/:sandbox_id/processes).

Fetch the last tail lines of logs for a process (GET /sandboxes/:sandbox_id/processes/:pid/logs?tail=N).

Send data to the stdin of a running background process (POST /sandboxes/:sandbox_id/processes/:pid/stdin).

Start a background process in the sandbox (POST /sandboxes/:sandbox_id/processes).

Stop (SIGTERM → SIGKILL after 5 s) a background process by its PID (DELETE /sandboxes/:sandbox_id/processes/:pid).

Functions

get(client, sandbox_id, pid)

Get a single process by PID (GET /sandboxes/:sandbox_id/processes/:pid).

kill(client, sandbox_id, pid)

@spec kill(Miosa.Client.t(), String.t(), String.t()) ::
  :ok | {:error, Miosa.Error.t()}

Alias for stop/3 (kept for backwards-compat).

list(client, sandbox_id)

List all running background processes in the sandbox (GET /sandboxes/:sandbox_id/processes).

logs(client, sandbox_id, pid, tail \\ 200)

Fetch the last tail lines of logs for a process (GET /sandboxes/:sandbox_id/processes/:pid/logs?tail=N).

send_stdin(client, sandbox_id, pid, data)

@spec send_stdin(Miosa.Client.t(), String.t(), String.t(), String.t()) ::
  Miosa.Client.result(map())

Send data to the stdin of a running background process (POST /sandboxes/:sandbox_id/processes/:pid/stdin).

start(client, sandbox_id, command, opts \\ %{})

@spec start(Miosa.Client.t(), String.t(), String.t(), map()) ::
  Miosa.Client.result(map())

Start a background process in the sandbox (POST /sandboxes/:sandbox_id/processes).

Options map keys

  • "cwd" — Working directory for the process.
  • "env" — Environment variables map.
  • "timeout" — Process timeout in seconds.

stop(client, sandbox_id, pid)

@spec stop(Miosa.Client.t(), String.t(), String.t()) ::
  :ok | {:error, Miosa.Error.t()}

Stop (SIGTERM → SIGKILL after 5 s) a background process by its PID (DELETE /sandboxes/:sandbox_id/processes/:pid).