public static void Main() { if (MultiAdminConfig.GlobalConfig.SafeServerShutdown.Value) { AppDomain.CurrentDomain.ProcessExit += OnExit; if (OperatingSystem.IsLinux()) { #if LINUX exitSignalListener = new UnixExitSignal(); #endif } else if (OperatingSystem.IsWindows()) { exitSignalListener = new WinExitSignal(); } if (exitSignalListener != null) { exitSignalListener.Exit += OnExit; } } // Remove executable path if (Args.Length > 0) { Args[0] = null; } Headless = GetFlagFromArgs(Args, "headless", "h"); string serverIdArg = GetParamFromArgs(Args, "server-id", "id"); string configArg = GetParamFromArgs(Args, "config", "c"); portArg = uint.TryParse(GetParamFromArgs(Args, "port", "p"), out uint port) ? (uint?)port : null; Server server = null; if (!string.IsNullOrEmpty(serverIdArg) || !string.IsNullOrEmpty(configArg)) { server = new Server(serverIdArg, configArg, portArg, Args); InstantiatedServers.Add(server); } else { if (Servers.IsEmpty()) { server = new Server(port: portArg, args: Args); InstantiatedServers.Add(server); } else { Server[] autoStartServers = AutoStartServers; if (autoStartServers.IsEmpty()) { Write("No servers are set to automatically start, please enter a Server ID to start:"); InputHandler.InputPrefix?.Write(); server = new Server(Console.ReadLine(), port: portArg, args: Args); InstantiatedServers.Add(server); } else { Write("Starting this instance in multi server mode..."); for (int i = 0; i < autoStartServers.Length; i++) { if (i == 0) { server = autoStartServers[i]; InstantiatedServers.Add(server); } else { StartServer(autoStartServers[i]); } } } } } if (server != null) { if (!string.IsNullOrEmpty(server.serverId) && !string.IsNullOrEmpty(server.configLocation)) { Write( $"Starting this instance with Server ID: \"{server.serverId}\" and config directory: \"{server.configLocation}\"..."); } else if (!string.IsNullOrEmpty(server.serverId)) { Write($"Starting this instance with Server ID: \"{server.serverId}\"..."); } else if (!string.IsNullOrEmpty(server.configLocation)) { Write($"Starting this instance with config directory: \"{server.configLocation}\"..."); } else { Write("Starting this instance in single server mode..."); } server.StartServer(); } }