2using System.Collections.Generic;
3using System.Diagnostics;
7using System.Threading.Tasks;
44 public static async Task<int>
Main(
string[] args)
50 return (
int)await program.Main(args, updatePath);
63 var potentialUpdatePath = args[0];
64 if (potentialUpdatePath.Equals(
"cli", StringComparison.OrdinalIgnoreCase))
67 var listArgs =
new List<string>(args);
71 if (listArgs.Count > 0)
73 var expectedHostWatchdogVersion = HostWatchdogVersion;
74 if (Version.TryParse(listArgs.First(), out var actualHostWatchdogVersion)
75 && actualHostWatchdogVersion.Major != expectedHostWatchdogVersion.Major)
76 throw new InvalidOperationException(
77 $
"Incompatible host watchdog version ({actualHostWatchdogVersion}) for server ({expectedHostWatchdogVersion})! A major update was released and a full restart will be required. Please manually offline your servers!");
80 if (listArgs.Remove(
"--attach-debugger"))
84 return potentialUpdatePath;
93 internal async ValueTask<HostExitCode>
Main(
string[] args,
string? updatePath)
98 var cancellationToken = shutdownNotifier.Token;
107 catch (OperationCanceledException)
116 await server.
Run(cancellationToken);
118 return server.RestartRequested
119 ? HostExitCode.RestartRequested
124 if (updatePath !=
null)
127 await
ServerFactory.
IOManager.WriteAllBytes(updatePath, Encoding.UTF8.GetBytes(e.ToString()), CancellationToken.None);
Sets up dependency injection.
static IServerFactory CreateDefaultServerFactory()
Create the default IServerFactory.
Entrypoint for the Process.
Program()
Initializes a new instance of the Program class.
static async Task< int > Main(string[] args)
Entrypoint for the Program.
static ? string TopLevelArgsParse(ref string[] args)
Parse Program top level args .
Attribute for bringing in the master versions list from MSBuild that aren't embedded into assemblies ...
string RawHostWatchdogVersion
The Version string of the host watchdog that was built alongside this TGS version.
static MasterVersionsAttribute Instance
Return the Assembly's instance of the MasterVersionsAttribute.
Implementation of IServerFactory.
IIOManager IOManager
The IIOManager for the IServerFactory.
async ValueTask< IServer?> CreateServer(string[] args, string? updatePath, CancellationToken cancellationToken)
Create a IServer.A ValueTask<TResult> resulting in a new IServer if it should be run,...
Contains a CancellationToken that triggers when the operating system requests the program shuts down.
ValueTask Run(CancellationToken cancellationToken)
Runs the IServer.
HostExitCode
Represents the exit code of the Host program.