Skip to content

Class Tryll::Client::ManagedServer

ClassList > Tryll > Client > ManagedServer

RAII handle around a child tryll_server process.More...

  • #include <ManagedServer.h>

Public Functions

Type Name
std::string Host () noexcept const
The host string from ManagedServerOptions::host .
bool IsRunning () noexcept const
Returns true while the child process is still running.
ManagedServer (ManagedServer &&) noexcept
ManagedServer (const ManagedServer &) = delete
std::uint16_t Port () noexcept const
The port from ManagedServerOptions::port .
void Stop (std::chrono::milliseconds timeout=std::chrono::seconds{8})
Release this handle without killing the server.
void Terminate (std::chrono::milliseconds timeout=std::chrono::seconds{8})
Immediately hard-kill the child process.
ManagedServer & operator= (ManagedServer &&) noexcept
ManagedServer & operator= (const ManagedServer &) = delete
~ManagedServer ()

Public Static Functions

Type Name
ManagedServer Start (const ManagedServerOptions & opts)
Spawn the server and block until its TCP port accepts connections.

Detailed Description

Move-only. The destructor calls Stop if the process is still running.

Public Functions Documentation

function Host

The host string from ManagedServerOptions::host .

std::string Tryll::Client::ManagedServer::Host () noexcept const


function IsRunning

Returns true while the child process is still running.

bool Tryll::Client::ManagedServer::IsRunning () noexcept const


function ManagedServer [1/3]

Tryll::Client::ManagedServer::ManagedServer (
    ManagedServer &&
) noexcept

function ManagedServer [2/3]

Tryll::Client::ManagedServer::ManagedServer (
    const ManagedServer &
) = delete

function Port

The port from ManagedServerOptions::port .

std::uint16_t Tryll::Client::ManagedServer::Port () noexcept const


function Stop

Release this handle without killing the server.

void Tryll::Client::ManagedServer::Stop (
    std::chrono::milliseconds timeout=std::chrono::seconds{8}
) 

Does not terminate the process. A managed server launched with idleShutdownTimeoutSeconds > 0 self-exits once no session is using it; this just drops our OS handle. Idempotent — safe to call more than once. Use Terminate for an immediate hard kill (e.g. the spawn succeeded but the handshake/connect afterward failed, so no session was ever created and nothing else can be relying on this process).

Parameters:

  • timeout Unused; kept for source compatibility.

function Terminate

Immediately hard-kill the child process.

void Tryll::Client::ManagedServer::Terminate (
    std::chrono::milliseconds timeout=std::chrono::seconds{8}
) 

Sends a termination signal and waits up to timeout for the process to exit; force-killed if it does not exit in time. Idempotent — safe to call more than once, including after Stop. Intended for failure paths where the caller knows this process is theirs and nothing else can depend on it (e.g. spawn succeeded but connect/handshake failed) — do not call this after a successful handshake, since another consumer could be relying on the server staying up until its own idle timeout.

Parameters:

  • timeout How long to wait for graceful exit before force-killing.

function operator=

ManagedServer & Tryll::Client::ManagedServer::operator= (
    ManagedServer &&
) noexcept

function operator=

ManagedServer & Tryll::Client::ManagedServer::operator= (
    const ManagedServer &
) = delete

function ~ManagedServer

Tryll::Client::ManagedServer::~ManagedServer () 

Public Static Functions Documentation

function Start

Spawn the server and block until its TCP port accepts connections.

static ManagedServer Tryll::Client::ManagedServer::Start (
    const ManagedServerOptions & opts
) 

The server is launched with --port <opts.port> so the port is authoritative from the caller's side regardless of server-config.json.

Parameters:

  • opts Launch options. opts.exe must exist.

Returns:

A ready-to-use ManagedServer.

Exception:

  • TryllError If the executable is not found, the process fails to start, the process exits before the port opens, or opts.startTimeout expires.


The documentation for this class was generated from the following file C:/_tryll/_monorepo3/tryll/clients/cpp/include/tryll/ManagedServer.h