Skip to main content

ServerCommandModule

A static class in Root.Township, Alta.Console.Commands.

Console module server: starts servers, proxies commands to other servers over their websocket console, and runs a spot-instance migration. Needs login, play mode and server_owner.

Fields​

1 private and internal field
MemberWhat it is
private static Logger loggerNLog logger for this module.

Methods​

10 private and internal methods
MemberWhat it is
private static async Task<bool> InformNewServerOfReadiness(int serverIdentifier)Sends server mark-ready to the new server over websocket during a migration; returns false on failure.
private static async Task Migrate(float secondsLeftUntilTermination = 120)Server: server migrate locks joins, warns players, stops for migration, asks the API for a new allocation, saves, signals the new server and shuts down.
private static Task MigrateClientToNewInstance(ConnectionInfo connectionToNewInstance)Placeholder for moving clients to the new server during migration; does nothing.
private static async Task Proxy(int serverId, string proxiedCommand)server proxy: sends a console command to another server through its websocket console.
private static async Task<AllocationResult> RequestMigrationFromWebApi(GameServerInfo activeServer)Asks the Alta API for a migration allocation, retrying every 5 seconds until it gets one.
private static Task SaveWorld()Saves the world instantly before a migration completes.
private static async Task SendPlayerCommunications(TimeSpan remainingTime)Sends migration warnings to all players now, a minute before and 10 seconds before termination.
private static async Task SendWebsocketMessage(int serverIdentifier, string message)Gets console connection details from the API, opens the server's websocket, authenticates with the token and sends one command request.
private static void ShutdownPostMigration(ShutdownReason reason)Quits the application after a migration with the given shutdown reason.
private static async void StartServerAsync(int serverId, bool isExternalLaunch = true, int port = 1757, bool isHeadless = true, bool isRunningLocally = true)server start: fetches a controllable server from the API and starts it, by default headless, launched externally on port 1757.