Class HostServerProcess
- Namespace
- Valheim.Testing.GameSessions
- Assembly
- Valheim.Testing.GameSessions.dll
A dedicated server HostServer started, identified by process ID and start time on its host. It is an IOwnedProcess, so an OwnedServerSession launches, checks and stops it like a local one. Stopping touches only that process, and only while its start time still matches (a process ID reused by another program is never touched): a clean stop (StopCleanly(TimeSpan, TimeSpan)) sends it SIGINT, on which the game saves, retires its PlayFab lobby and quits, and kills it only if it has not exited in time. Then it keeps the boot's logs in its boot directory and, when an evidence directory was given, fetches that directory here. Disposing kills it if it was not stopped yet.
public sealed class HostServerProcess : IOwnedProcess
- Inheritance
-
objectHostServerProcess
- Implements
Properties
BootDirectory
This boot's evidence directory on the host.
public string BootDirectory { get; }
Property Value
- string
EvidenceDirectory
Where stopping fetches the boot directory, or null.
public string? EvidenceDirectory { get; }
Property Value
- string
EvidenceTimeout
How long fetching the evidence may take.
public TimeSpan EvidenceTimeout { get; init; }
Property Value
- TimeSpan
HasExited
True once a wait or a stop saw the process gone. Not a live check: use WaitForExitAsync(CancellationToken) for that.
public bool HasExited { get; }
Property Value
- bool
HostName
public string HostName { get; }
Property Value
- string
Id
The server's process ID on its host.
public int Id { get; }
Property Value
- int
Runtime
public string Runtime { get; }
Property Value
- string
StartIdentity
The host-specific start identity, which tells this process from a later process with the same ID.
public string StartIdentity { get; }
Property Value
- string
TaskLogon
On Windows, how the task that started this server logged on: s4u (session 0) or interactive (the user's desktop session).
public string? TaskLogon { get; }
Property Value
- string
Methods
Dispose()
Stops the process unless it was stopped already; an unproven stop throws.
public void Dispose()
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
Stop(TimeSpan)
The IOwnedProcess stop: StopAsync(TimeSpan, CancellationToken), waited for.
public void Stop(TimeSpan timeout)
Parameters
timeoutTimeSpan
StopAsync(TimeSpan, CancellationToken)
Kills the process if it is still the one this boot started and waits up to timeout for it to exit, then
keeps the logs and fetches the evidence. Each part is done once; a call after a failure repeats only what is left, which
the identity check makes safe. A process still there after the kill, or an unproven stop or fetch, throws.
public Task<HostServerStop> StopAsync(TimeSpan timeout, CancellationToken cancellation = default)
Parameters
timeoutTimeSpancancellationCancellationToken
Returns
- Task<HostServerStop>
StopAsync(TimeSpan, TimeSpan, CancellationToken)
StopAsync(TimeSpan, CancellationToken), but first sends the server SIGINT and gives it quit
to save and exit by itself, which it reports as Quit; only then is it killed.
public Task<HostServerStop> StopAsync(TimeSpan quit, TimeSpan timeout, CancellationToken cancellation = default)
Parameters
quitTimeSpantimeoutTimeSpancancellationCancellationToken
Returns
- Task<HostServerStop>
StopCleanly(TimeSpan, TimeSpan)
The IOwnedProcess clean stop: StopAsync(TimeSpan, TimeSpan, CancellationToken), waited for.
public ProcessStop StopCleanly(TimeSpan quit, TimeSpan kill)
Parameters
quitTimeSpankillTimeSpan
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
WaitForExitAsync(CancellationToken)
Completes when the process has exited, with the exit code the launch's recorder wrote, otherwise -1. Waits on the host in rounds of at most 10 minutes until cancelled; a round whose reply is lost throws HostOperationException.
public Task<int> WaitForExitAsync(CancellationToken cancellation)
Parameters
cancellationCancellationToken
Returns
- Task<int>