static void Main(string[] args) { var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "log4net.xml"))); Log.Info(MiNetServer.MiNET); System.Console.WriteLine(MiNetServer.MiNET); var currentProcess = Process.GetCurrentProcess(); currentProcess.ProcessorAffinity = (IntPtr)Config.GetProperty("ProcessorAffinity", (int)currentProcess.ProcessorAffinity); var service = new MiNetServer(); Log.Info("Starting..."); if (Config.GetProperty("UserBedrockGenerator", false)) { service.LevelManager = new LevelManager(); service.LevelManager.Generator = new BedrockGenerator(); } service.StartServer(); System.Console.WriteLine("MiNET running. Press <enter> to stop service."); System.Console.ReadLine(); service.StopServer(); }
protected override void OnEnable() { _log.Warn("Loaded"); Task task = Task.Factory.StartNew(() => { _server.StopServer(); }); }
public static void Main(string[] args) { Console.WriteLine("Starting MiNET Server..."); MiNetServer server = new MiNetServer(); server.StartServer(); Console.WriteLine("MiNET Server started! Press <Enter> to exit"); Console.ReadLine(); Console.WriteLine("Stopping MiNET Server..."); server.StopServer(); }
static void Main(string[] args) { if (args.Length > 0 && args[0] == "listener") { // This is a brutal hack to block BDS to use the ports we are using. So we start this, and basically block BDS // while it is starting. Then we close down this process again, and continue on our way. var reset = new ManualResetEvent(false); using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp) { ExclusiveAddressUse = true }; socket.Bind(new IPEndPoint(IPAddress.Any, 19132)); System.Console.WriteLine("LISTENING!"); reset.WaitOne(); System.Console.WriteLine("EXIT!"); return; } var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "log4net.xml"))); Log.Info(MiNetServer.MiNET); System.Console.WriteLine(MiNetServer.MiNET); var currentProcess = Process.GetCurrentProcess(); currentProcess.ProcessorAffinity = (IntPtr)Config.GetProperty("ProcessorAffinity", (int)currentProcess.ProcessorAffinity); var service = new MiNetServer(); Log.Info("Starting..."); if (Config.GetProperty("UserBedrockGenerator", false)) { service.LevelManager = new LevelManager(); service.LevelManager.Generator = new BedrockGenerator(); } service.StartServer(); System.Console.WriteLine("MiNET running. Press <enter> to stop service."); System.Console.ReadLine(); service.StopServer(); }
static void Main(string[] args) { var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo("log4net.xml")); System.Console.WriteLine(MiNetServer.MiNET); Log.Info(MiNetServer.MiNET); var service = new MiNetServer(); Log.Info("Starting..."); service.StartServer(); System.Console.WriteLine("MiNET running. Press <enter> to stop service."); System.Console.ReadLine(); service.StopServer(); }
static void Main(string[] args) { var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo("log4net.xml")); int threads; int portThreads; ThreadPool.GetMinThreads(out threads, out portThreads); Log.Info($"Threads: {threads}, Port Threads: {portThreads}"); var service = new MiNetServer(); Log.Info("Starting MiNET"); service.StartServer(); System.Console.WriteLine("MiNET running. Press <enter> to stop service."); System.Console.ReadLine(); service.StopServer(); }
public void StopServer() { _server.StopServer(); }
/// <summary> /// Stops this instance. /// </summary> public void Stop() { Log.Info("Stopping RaNET"); _server.StopServer(); }
/// <summary> /// Stops this instance. /// </summary> private void Stop() { Log.Info("Stopping MiNET"); _server.StopServer(); }
public static void TriggerReboot(bool force = false) { if (Timer != null) { Timer.Dispose(); Timer = null; } else { SkyUtil.log("Attempted to double-trigger a reboot! Ignoring..."); return; //If Timer == null, there should already be a reboot happening. } SkyUtil.log("Shutting down using Restart Handler"); SkyUtil.log("Moving all players to first available hub"); //Remove this instance from the game pool string gameType = SkyCoreAPI.Instance.GameType; if (ExternalGameHandler.GameRegistrations.TryGetValue(gameType, out GamePool gamePool)) { List <InstanceInfo> toRemoveInstances = new List <InstanceInfo>(); foreach (InstanceInfo instanceInfo in gamePool.GetAllInstances()) { if (instanceInfo.HostAddress.Equals("local")) { toRemoveInstances.Add(instanceInfo); } } foreach (InstanceInfo toRemoveInstance in toRemoveInstances) { gamePool.RemoveInstance(toRemoveInstance); } } //Remove ourselves from the list, and force players to a new hub if (gamePool != null && gameType.Equals("hub")) { if (gamePool.GetAllInstances().Count > 0) { foreach (SkyPlayer player in SkyCoreAPI.Instance.GetAllOnlinePlayers()) { ExternalGameHandler.AddPlayer(player, "hub"); } //Wait for players to leave Thread.Sleep(5000); } //else - No hub servers to send players to. Forfeit all players. } else { SkyCoreAPI.IsRebootQueued = true; //Force will ignore this and kick all players immediately if (!force && SkyCoreAPI.Instance.GameModes.TryGetValue(gameType, out GameController localGameController) && !localGameController.GameLevels.IsEmpty) { ICollection <GameLevel> gameLevels = localGameController.GameLevels.Values; long expiryForceTime = DateTimeOffset.Now.ToUnixTimeSeconds() + 300; //5 minute timeout if the game is still running int totalPlayers; do { totalPlayers = 0; foreach (GameLevel gameLevel in gameLevels) { if (gameLevel.CurrentState.GetEnumState(gameLevel).IsJoinable()) { //We're allowed to kick all players foreach (SkyPlayer player in gameLevel.GetAllPlayers()) { ExternalGameHandler.AddPlayer(player, "hub"); } } else { totalPlayers += gameLevel.GetAllPlayers().Count; } } if (totalPlayers > 0) { SkyUtil.log( $"Waiting for {totalPlayers} to finish games before closing this instance {expiryForceTime - DateTimeOffset.Now.ToUnixTimeSeconds()} seconds remaining."); Thread.Sleep(15000); //Check every 1 second if the game has finished } } while (totalPlayers > 0 && DateTimeOffset.Now.ToUnixTimeSeconds() < expiryForceTime); } } SkyUtil.log("Shutting down..."); //Start Actual Shutdown MiNetServer server = SkyCoreAPI.Instance.Server; try { if (server.PluginManager.Plugins.Count > 1) { foreach (object pluginObject in server.PluginManager.Plugins) { if (pluginObject is IPlugin plugin) { plugin.OnDisable(); } } server.PluginManager.Plugins.Clear(); } else { SkyCoreAPI.Instance.OnDisable(); } } catch (Exception e) { BugSnagUtil.ReportBug(e); } try { server.StopServer(); } catch (Exception e) { BugSnagUtil.ReportBug(e); } Environment.Exit(0); }