tgstation-server 6.12.0
The /tg/station 13 server suite
|
Public Member Functions | |||||
Server (IHostBuilder hostBuilder, string? updatePath) | |||||
Initializes a new instance of the Server class. | |||||
async ValueTask | Run (CancellationToken cancellationToken) | ||||
Runs the IServer.
| |||||
bool | TryStartUpdate (IServerUpdateExecutor updateExecutor, Version newVersion) | ||||
Attempt to update with a given updateExecutor .
| |||||
IRestartRegistration | RegisterForRestart (IRestartHandler handler) | ||||
Register a given handler to run before stopping the server for a restart.
| |||||
ValueTask | Restart () | ||||
Restarts the Host.
| |||||
ValueTask | GracefulShutdown (bool detach) | ||||
Gracefully shutsdown the Host.
| |||||
ValueTask | Die (Exception? exception) | ||||
Kill the server with a fatal exception.
| |||||
Properties | |
bool | RestartRequested [get, private set] |
If the IServer should restart. | |
bool | UpdateInProgress [get, private set] |
Whether or not the server is currently updating. | |
bool | WatchdogPresent [get] |
true if live updates are supported, false . TryStartUpdate(IServerUpdateExecutor, Version) and Restart will fail if this is false . | |
Properties inherited from Tgstation.Server.Host.IServer | |
Properties inherited from Tgstation.Server.Host.Core.IServerControl |
Private Member Functions | |
async ValueTask< bool > | DumpGraphQLSchemaIfRequested (IServiceProvider services, CancellationToken cancellationToken) |
Checks if InternalConfiguration.DumpGraphQLApiPath is set and dumps the GraphQL API Schema to it if so. | |
void | CheckSanity (bool checkWatchdog) |
Throws an InvalidOperationException if the IServerControl cannot be used. | |
void | CheckExceptionPropagation (Exception? otherException) |
Re-throw propagatedException if it exists. | |
async ValueTask | RestartImpl (Version? newVersion, Exception? exception, bool requireWatchdog, bool completeAsap) |
Implements Restart(). | |
void | WatchForShutdownFileCreation (object sender, FileSystemEventArgs eventArgs) |
Event handler for the updatePath's FileSystemWatcher. Triggers shutdown if requested by host watchdog. | |
void | StopServerImmediate () |
Fires off the cancellationTokenSource without any checks, shutting down everything. | |
Private Attributes | |
readonly IHostBuilder | hostBuilder |
The IHostBuilder for the Server. | |
readonly List< IRestartHandler > | restartHandlers |
The IRestartHandlers to run when the Server restarts. | |
readonly? string | updatePath |
The absolute path to install updates to. | |
readonly object | restartLock |
lock object for certain restart related operations. | |
ILogger< Server >? | logger |
The ILogger for the Server. | |
GeneralConfiguration? | generalConfiguration |
The GeneralConfiguration for the Server. | |
CancellationTokenSource? | cancellationTokenSource |
The cancellationTokenSource for the Server. | |
Exception? | propagatedException |
The Exception to propagate when the server terminates. | |
Task? | updateTask |
The Task that is used for asynchronously updating the server. | |
bool | shutdownInProgress |
If the server is being shut down or restarted. | |
bool | terminateIfUpdateFails |
If there is an update in progress and this flag is set, it should stop the server immediately if it fails. | |
Tgstation.Server.Host.Server.Server | ( | IHostBuilder | hostBuilder, |
string? | updatePath | ||
) |
Initializes a new instance of the Server class.
hostBuilder | The value of hostBuilder. |
updatePath | The value of updatePath. |
Definition at line 106 of file Server.cs.
References Tgstation.Server.Host.Server.hostBuilder, Tgstation.Server.Host.Server.logger, Tgstation.Server.Host.Server.restartHandlers, Tgstation.Server.Host.Server.restartLock, and Tgstation.Server.Host.Server.updatePath.
|
private |
Re-throw propagatedException if it exists.
otherException | An existing Exception that should be thrown as well, but not by itself. |
Definition at line 332 of file Server.cs.
References Tgstation.Server.Host.Server.propagatedException.
Referenced by Tgstation.Server.Host.Server.Run().
|
private |
Throws an InvalidOperationException if the IServerControl cannot be used.
checkWatchdog | If WatchdogPresent should be checked. |
Definition at line 319 of file Server.cs.
References Tgstation.Server.Host.Server.cancellationTokenSource, Tgstation.Server.Host.Server.logger, Tgstation.Server.Host.Server.propagatedException, and Tgstation.Server.Host.Server.WatchdogPresent.
Referenced by Tgstation.Server.Host.Server.RegisterForRestart(), Tgstation.Server.Host.Server.RestartImpl(), and Tgstation.Server.Host.Server.TryStartUpdate().
ValueTask Tgstation.Server.Host.Server.Die | ( | Exception? | exception | ) |
Kill the server with a fatal exception.
exception | The Exception to propagate to the watchdog if any. |
Implements Tgstation.Server.Host.Core.IServerControl.
Definition at line 281 of file Server.cs.
References Tgstation.Server.Host.Server.RestartImpl(), and Tgstation.Server.Host.Server.StopServerImmediate().
|
private |
Checks if InternalConfiguration.DumpGraphQLApiPath is set and dumps the GraphQL API Schema to it if so.
services | The IServiceProvider to resolve services from. |
cancellationToken | The CancellationToken for the operation. |
true
if the GraphQL API was dumped, false
otherwise.Definition at line 296 of file Server.cs.
References Tgstation.Server.Host.Server.logger, and Tgstation.Server.Host.IO.IIOManager.WriteAllBytes().
Referenced by Tgstation.Server.Host.Server.Run().
ValueTask Tgstation.Server.Host.Server.GracefulShutdown | ( | bool | detach | ) |
Gracefully shutsdown the Host.
detach | If the graceful shutdown should detach any running watchdog. If false the server will wait for the next TgsReboot() or world exit before shutting down. |
Implements Tgstation.Server.Host.Core.IServerControl.
IRestartRegistration Tgstation.Server.Host.Server.RegisterForRestart | ( | IRestartHandler | handler | ) |
Register a given handler to run before stopping the server for a restart.
handler | The IRestartHandler to register. |
Implements Tgstation.Server.Host.Core.IServerControl.
Definition at line 249 of file Server.cs.
References Tgstation.Server.Host.Server.CheckSanity(), Tgstation.Server.Host.Server.logger, Tgstation.Server.Host.Server.restartHandlers, Tgstation.Server.Host.Server.restartLock, and Tgstation.Server.Host.Server.shutdownInProgress.
ValueTask Tgstation.Server.Host.Server.Restart | ( | ) |
Restarts the Host.
Implements Tgstation.Server.Host.Core.IServerControl.
Referenced by Tgstation.Server.Host.Components.Watchdog.AdvancedWatchdog.HandleNormalReboot().
|
private |
Implements Restart().
newVersion | The Version of any potential updates being applied. |
exception | The potential value of propagatedException. |
requireWatchdog | If the host watchdog is required for this "restart". |
completeAsap | If the restart should wait for extremely long running tasks to complete (Like the current DreamDaemon world). |
Definition at line 351 of file Server.cs.
References Tgstation.Server.Host.Server.CheckSanity(), Tgstation.Server.Host.Server.generalConfiguration, Tgstation.Server.Host.Server.logger, Tgstation.Server.Host.Server.propagatedException, Tgstation.Server.Host.Server.restartHandlers, Tgstation.Server.Host.Server.restartLock, Tgstation.Server.Host.Server.RestartRequested, Tgstation.Server.Host.Configuration.GeneralConfiguration.RestartTimeoutMinutes, Tgstation.Server.Host.Server.shutdownInProgress, Tgstation.Server.Host.Configuration.GeneralConfiguration.ShutdownTimeoutMinutes, Tgstation.Server.Host.Server.StopServerImmediate(), Tgstation.Server.Host.Server.UpdateInProgress, and Tgstation.Server.Common.Extensions.ValueTaskExtensions.WhenAll().
Referenced by Tgstation.Server.Host.Server.Die(), and Tgstation.Server.Host.Server.TryStartUpdate().
async ValueTask Tgstation.Server.Host.Server.Run | ( | CancellationToken | cancellationToken | ) |
Runs the IServer.
cancellationToken | The CancellationToken for the operation. |
Implements Tgstation.Server.Host.IServer.
Definition at line 119 of file Server.cs.
References Tgstation.Server.Host.Server.cancellationTokenSource, Tgstation.Server.Host.Server.CheckExceptionPropagation(), Tgstation.Server.Host.Server.DumpGraphQLSchemaIfRequested(), Tgstation.Server.Host.Server.generalConfiguration, Tgstation.Server.Host.Server.hostBuilder, Tgstation.Server.Host.Server.logger, Tgstation.Server.Host.Server.updatePath, Tgstation.Server.Host.Server.updateTask, and Tgstation.Server.Host.Server.WatchForShutdownFileCreation().
|
private |
Fires off the cancellationTokenSource without any checks, shutting down everything.
Definition at line 450 of file Server.cs.
References Tgstation.Server.Host.Server.cancellationTokenSource, Tgstation.Server.Host.Server.logger, and Tgstation.Server.Host.Server.shutdownInProgress.
Referenced by Tgstation.Server.Host.Server.Die(), Tgstation.Server.Host.Server.RestartImpl(), and Tgstation.Server.Host.Server.WatchForShutdownFileCreation().
bool Tgstation.Server.Host.Server.TryStartUpdate | ( | IServerUpdateExecutor | updateExecutor, |
Version | newVersion | ||
) |
Attempt to update with a given updateExecutor .
updateExecutor | The IServerUpdateExecutor to use for the update. |
newVersion | The Version the IServerControl is updating to. |
true
if the update started successfully, false
if there was another update in progress.Implements Tgstation.Server.Host.Core.IServerControl.
Definition at line 180 of file Server.cs.
References Tgstation.Server.Host.Server.cancellationTokenSource, Tgstation.Server.Host.Server.CheckSanity(), Tgstation.Server.Host.Core.IServerUpdateExecutor.ExecuteUpdate(), Tgstation.Server.Host.Server.logger, Tgstation.Server.Host.Server.RestartImpl(), Tgstation.Server.Host.Server.restartLock, Tgstation.Server.Host.Server.shutdownInProgress, Tgstation.Server.Host.Server.terminateIfUpdateFails, Tgstation.Server.Host.Server.UpdateInProgress, Tgstation.Server.Host.Server.updatePath, and Tgstation.Server.Host.Server.updateTask.
|
private |
Event handler for the updatePath's FileSystemWatcher. Triggers shutdown if requested by host watchdog.
sender | The object that sent the event. |
eventArgs | The FileSystemEventArgs. |
Definition at line 424 of file Server.cs.
References Tgstation.Server.Host.Server.logger, Tgstation.Server.Host.Server.restartLock, Tgstation.Server.Host.Server.StopServerImmediate(), Tgstation.Server.Host.Server.terminateIfUpdateFails, Tgstation.Server.Host.Server.UpdateInProgress, and Tgstation.Server.Host.Server.updatePath.
Referenced by Tgstation.Server.Host.Server.Run().
|
private |
The cancellationTokenSource for the Server.
Definition at line 79 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.CheckSanity(), Tgstation.Server.Host.Server.Run(), Tgstation.Server.Host.Server.StopServerImmediate(), and Tgstation.Server.Host.Server.TryStartUpdate().
|
private |
The GeneralConfiguration for the Server.
Definition at line 74 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.RestartImpl(), and Tgstation.Server.Host.Server.Run().
|
private |
The IHostBuilder for the Server.
Definition at line 49 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.Run(), and Tgstation.Server.Host.Server.Server().
|
private |
The ILogger for the Server.
Definition at line 69 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.CheckSanity(), Tgstation.Server.Host.Server.DumpGraphQLSchemaIfRequested(), Tgstation.Server.Host.Server.RegisterForRestart(), Tgstation.Server.Host.Server.RestartImpl(), Tgstation.Server.Host.Server.Run(), Tgstation.Server.Host.Server.Server(), Tgstation.Server.Host.Server.StopServerImmediate(), Tgstation.Server.Host.Server.TryStartUpdate(), and Tgstation.Server.Host.Server.WatchForShutdownFileCreation().
|
private |
The Exception to propagate when the server terminates.
Definition at line 84 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.CheckExceptionPropagation(), Tgstation.Server.Host.Server.CheckSanity(), and Tgstation.Server.Host.Server.RestartImpl().
|
private |
The IRestartHandlers to run when the Server restarts.
Definition at line 54 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.RegisterForRestart(), Tgstation.Server.Host.Server.RestartImpl(), and Tgstation.Server.Host.Server.Server().
|
private |
lock
object for certain restart related operations.
Definition at line 64 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.RegisterForRestart(), Tgstation.Server.Host.Server.RestartImpl(), Tgstation.Server.Host.Server.Server(), Tgstation.Server.Host.Server.TryStartUpdate(), and Tgstation.Server.Host.Server.WatchForShutdownFileCreation().
|
private |
If the server is being shut down or restarted.
Definition at line 94 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.RegisterForRestart(), Tgstation.Server.Host.Server.RestartImpl(), Tgstation.Server.Host.Server.StopServerImmediate(), and Tgstation.Server.Host.Server.TryStartUpdate().
|
private |
If there is an update in progress and this flag is set, it should stop the server immediately if it fails.
Definition at line 99 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.TryStartUpdate(), and Tgstation.Server.Host.Server.WatchForShutdownFileCreation().
|
private |
The absolute path to install updates to.
Definition at line 59 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.Run(), Tgstation.Server.Host.Server.Server(), Tgstation.Server.Host.Server.TryStartUpdate(), and Tgstation.Server.Host.Server.WatchForShutdownFileCreation().
|
private |
The Task that is used for asynchronously updating the server.
Definition at line 89 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.Run(), and Tgstation.Server.Host.Server.TryStartUpdate().
|
getprivate set |
If the IServer should restart.
Implements Tgstation.Server.Host.IServer.
Definition at line 28 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.RestartImpl().
|
getprivate set |
Whether or not the server is currently updating.
Implements Tgstation.Server.Host.Core.IServerControl.
Definition at line 31 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.RestartImpl(), Tgstation.Server.Host.Server.TryStartUpdate(), and Tgstation.Server.Host.Server.WatchForShutdownFileCreation().
|
get |
true
if live updates are supported, false
. TryStartUpdate(IServerUpdateExecutor, Version) and Restart will fail if this is false
.
Implements Tgstation.Server.Host.Core.IServerControl.
Definition at line 34 of file Server.cs.
Referenced by Tgstation.Server.Host.Server.CheckSanity().