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})
Terminate 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

Terminate the child process.

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

Sends a termination signal and waits up to timeout for the process to exit. If the process does not exit in time it is force-killed. Idempotent — safe to call more than once.

Parameters:

  • timeout Override for the stop timeout set in the options.

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/_monorepo/server/client-cpp/include/tryll/ManagedServer.h