ExAthena.Terminal.Server (ExAthena v0.17.0)

Copy Markdown View Source

One GenServer per embedded web terminal.

Owns an interactive shell via erlexec (a real pseudo-terminal: prompt, colors, job control, Ctrl-C), streams its output to the owning LiveView as themed HTML, and dies with its owner (shared-fate cleanup). Output is coalesced on a short timer so a flood (yes, a big cat) becomes a few LiveView diffs instead of thousands of messages.

Started on demand under ExAthena.Terminal.Supervisor, named by terminal id in ExAthena.Terminal.Registry (mirrors Orchestrator.Coordinator).

This is a COMMAND-RUNNER terminal — line-streaming with SGR colors. The output renderer (ExAthena.Terminal.Sgr) does not emulate cursor control, so full-screen TUIs (vim/htop) are out of scope by design.

Summary

Functions

Returns a specification to start this module under a supervisor.

Feed raw input (a command line, usually ending in \n) to the shell.

Send Ctrl-C (SIGINT) to the foreground command.

Re-send the captured scrollback to the owner (client (re)connect).

Resize the pty (rows × cols).

Start (or fetch) a terminal under the DynamicSupervisor.

Kill the shell and stop the server.

Functions

alive?(id)

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

input(id, data)

Feed raw input (a command line, usually ending in \n) to the shell.

interrupt(id)

Send Ctrl-C (SIGINT) to the foreground command.

replay(id)

Re-send the captured scrollback to the owner (client (re)connect).

resize(id, rows, cols)

Resize the pty (rows × cols).

start_for(opts)

Start (or fetch) a terminal under the DynamicSupervisor.

start_link(opts)

stop(id)

Kill the shell and stop the server.