Class EnvironmentRuns
- Namespace
- Valheim.Testing.GameSessions
- Assembly
- Valheim.Testing.GameSessions.dll
What an EnvironmentInventory does across its hosts (valheim-test env status|recover|teardown and a bare
env preflight's journal check): reads each host's run journal, recovers or tears down what one run left, releases the
leases of a run whose machine is gone, removes one unjournalled copy. Also where a session's actors and a standalone run's
server are placed on the inventory's environments. The inventory itself only describes the hosts and environments.
public static class EnvironmentRuns
- Inheritance
-
objectEnvironmentRuns
Methods
LocalJournalProblemsAsync(EnvironmentInventory, CancellationToken)
What a bare valheim-test env preflight refuses from this machine's journals (its own and the inventory's local
hosts'; another host's is read by valheim-test session check --hosts): a run of another process still going here, one
that left something (recoverable or not) and was not recovered, one that may still be going, and a journal that cannot be
read. The same wording as the campaign's journal check. Changes nothing.
public static Task<IReadOnlyList<CampaignPreflightProblem>> LocalJournalProblemsAsync(this EnvironmentInventory inventory, CancellationToken cancellation = default)
Parameters
inventoryEnvironmentInventorycancellationCancellationToken
Returns
- Task<IReadOnlyList<CampaignPreflightProblem>>
RecoverRunAsync(string?, string, bool, TextWriter, bool, CancellationToken)
Clears what run runId left on the hosts of the inventory at inventoryPath (this
machine when null), as WriteRunStatusAsync(string?, TextWriter, bool, CancellationToken) judged it, and writes what was done. A run that is still going,
whose runner cannot be checked, or that left anything that cannot be proven its own is refused before anything changes.
A process is stopped only when its ID, start time and command line still all match the run's journal. Copies and leases
the run kept on purpose stay unless teardown; a world copy, a run's save, is handed over to the output
it is in, never removed by a run's recovery. Returns true only when post-recovery status says nothing of the run is left.
public static Task<bool> RecoverRunAsync(string? inventoryPath, string runId, bool teardown, TextWriter output, bool json = false, CancellationToken cancellation = default)
Parameters
inventoryPathstringrunIdstringteardownbooloutputTextWriterjsonboolcancellationCancellationToken
Returns
- Task<bool>
ReleaseLeasesOfGoneRunAsync(string?, string, TextWriter, CancellationToken)
The escape hatch for a run whose machine is gone for good (valheim-test env teardown --run ID --machine-gone): a
lease never lapses (#257), so a run that can no longer be recovered would otherwise hold its Steam accounts forever (as
would a claim whose reply was lost, which no journal names). On the inventory's lease host, it releases every unreleased
lease that names runId and journals each release there as the maintainer's (machineGone). The
flag is the maintainer's confirmation that no client of that run can still run; a client that does is not told. When it
released a lease of a run no readable journal had ended (unknown, or journalled only on the gone machine), the run is
journalled there as ended too, so env status and preflight stop waiting for it; nothing else of the run is touched.
Refused when the run is still going, when the lease host's journal cannot be read, and when every host was read and
env recover|teardown --run can settle the run (its clients can be proven stopped). Returns true when nothing the
run held is left unreleased.
public static Task<bool> ReleaseLeasesOfGoneRunAsync(string? inventoryPath, string runId, TextWriter output, CancellationToken cancellation = default)
Parameters
inventoryPathstringrunIdstringoutputTextWritercancellationCancellationToken
Returns
- Task<bool>
TeardownCopyAsync(string?, string, TextWriter, CancellationToken)
Removes one copy on this machine that no run's journal names (made before runs journalled their copies), keeping what
its run changed in <copy>-changes beside it (Remove(string, bool)). Refuses a copy a journal names
(RecoverRunAsync(string?, string, bool, TextWriter, bool, CancellationToken) owns those) and one a running process uses. Returns true when it was removed.
public static Task<bool> TeardownCopyAsync(string? inventoryPath, string copyPath, TextWriter output, CancellationToken cancellation = default)
Parameters
inventoryPathstringcopyPathstringoutputTextWritercancellationCancellationToken
Returns
- Task<bool>
WriteRunStatusAsync(string?, TextWriter, bool, CancellationToken)
Writes what earlier runs left on each host of the inventory at inventoryPath (this machine when null),
from each host's run journal (journal beside the host's lock): every run that has not ended, or left copies,
disposable characters, processes, Steam leases or host locks it never journalled as gone, each checked on its host.
Only the hosts are needed, not an install. Changes nothing. Returns true when every host was read and every run left
nothing. json writes the report as JSON instead of text (without the detected: lines).
public static Task<bool> WriteRunStatusAsync(string? inventoryPath, TextWriter output, bool json = false, CancellationToken cancellation = default)
Parameters
inventoryPathstringoutputTextWriterjsonboolcancellationCancellationToken
Returns
- Task<bool>