plesty.server.model.process

What the bench remembers and observes about a running device server.

A ProcessRecord is written when a server is launched and read by every later plesty-server process — the CLI, the agent, the GUI — so all of them see the same servers. A ProcessStatus is what one of them concludes right now from the record, the process table and a protocol probe.

Attributes

STOPPED

STARTING

RUNNING

EXITED

STATES

Classes

ProcessRecord

What the supervisor persists about a started server.

ProcessStatus

The observed state of one device server.

Module Contents

plesty.server.model.process.STOPPED = 'stopped'
plesty.server.model.process.STARTING = 'starting'
plesty.server.model.process.RUNNING = 'running'
plesty.server.model.process.EXITED = 'exited'
plesty.server.model.process.STATES
class plesty.server.model.process.ProcessRecord

What the supervisor persists about a started server.

Variables:
  • name – Device instance name.

  • pid – Process id of the launcher that owns the server.

  • port – TCP port it was told to bind.

  • started_utc – ISO timestamp of the launch.

  • command – The full command line.

  • cwd – Working directory the server runs in.

  • log – Path of the log file its output goes to.

  • python – The interpreter — what a relaunch has to repeat.

  • module – The python -m target — likewise.

  • args – The spec’s arguments — likewise.

  • env – The spec’s environment — likewise.

  • package – Distribution the server runs, for listings.

  • version – Its installed version, for listings.

name: str
pid: int
port: int
started_utc: str
command: list[str]
cwd: str
log: str
python: str = ''
module: str = ''
args: list[str] = []
env: dict[str, str]
package: str = ''
version: str = ''
to_dict() dict[str, Any]

JSON form.

Return type:

dict[str, Any]

classmethod from_dict(data: collections.abc.Mapping[str, Any]) ProcessRecord

Rebuild a record from to_dict() output (extra keys ignored).

Parameters:

data (collections.abc.Mapping[str, Any])

Return type:

ProcessRecord

classmethod load(path: pathlib.Path) ProcessRecord | None

Read a record file; None when absent or unreadable.

Parameters:

path (pathlib.Path)

Return type:

ProcessRecord | None

save(path: pathlib.Path) pathlib.Path

Write the record to path; returns it.

Parameters:

path (pathlib.Path)

Return type:

pathlib.Path

class plesty.server.model.process.ProcessStatus

The observed state of one device server.

Variables:
  • name – Device instance name.

  • state – One of STATES.

  • pid – Process id when a record exists.

  • port – Probed port when a record exists.

  • started_utc – Launch time when a record exists.

  • log – Log path when a record exists.

  • returncode – Exit code for an exited server, when the launcher recorded one (-1 when it vanished without).

  • detail – For an exited server, the tail of its log — why it died.

name: str
state: str
pid: int | None = None
port: int | None = None
started_utc: str | None = None
log: str | None = None
returncode: int | None = None
detail: str = ''
property alive: bool

Whether the process exists (running or still starting).

Return type:

bool

to_dict() dict[str, Any]

JSON form (what status prints and the agent returns).

Return type:

dict[str, Any]