コード例 #1
0
        public static void ServerUpdateWValidate(ArkServerInfo Server)
        {
            string command = Server.SteamCMDDir + "SteamCMD.exe " + "+login anonymous +force_install_dir " + Server.ServerDir + " +app_update 376030 validate";

            command = command + " +force_install_dir " + Server.SteamWorkshopDownloadDir;
            foreach (string mod in GlobalVariables.ActiveServerMods(Server))
            {
                command = command + " +workshop_download_item 346110 " + mod;
            }

            command = command + " +quit";


            Process steamUpdateServer = new Process();

            steamUpdateServer.StartInfo.UseShellExecute        = false;
            steamUpdateServer.StartInfo.RedirectStandardInput  = true;
            steamUpdateServer.StartInfo.RedirectStandardOutput = true;
            //steamUpdateServer.StartInfo.CreateNoWindow = false;
            steamUpdateServer.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            steamUpdateServer.EnableRaisingEvents   = true;
            steamUpdateServer.StartInfo.FileName    = "cmd.exe";
            steamUpdateServer.Exited += (sender, e) =>
            {
                //Console.WriteLine(DateTime.Now + ": Process Complete for " + Server.Name + "    Time: {0} sec " +
                //"Exit code:    {1}", DateTime.Now.Second - steamUpdateServer.StartTime.Second, steamUpdateServer.ExitCode);
                Methods.Log(Server, DateTime.Now + ": Process Complete for " + Server.Name + " Time: " + (DateTime.Now.Second - steamUpdateServer.StartTime.Second) + " sec " +
                            "Exit code: " + steamUpdateServer.ExitCode);
                Server.CurrentlyUpdating = false;

                if (!Server.stopServerTimer)
                {
                    Server.GameUpdateNeeded = GlobalVariables.NeedsArkUpdate(Server);
                    Server.ModUpdateNeeded  = GlobalVariables.NeedsModUpdate(Server);
                }
                Methods.StartServerProcedure(Server);
                ((Process)sender).Dispose();
            };
            steamUpdateServer.Start();
            //Console.WriteLine(DateTime.Now + ": Running ServerUpdate with Validate method for " + Server.Name);
            Methods.Log(Server, DateTime.Now + ": Running ServerUpdate with Validate method for " + Server.Name);
            steamUpdateServer.StandardOutput.ReadToEndAsync();
            steamUpdateServer.StandardInput.WriteLine(command);
            Server.CurrentlyUpdating = true;
            steamUpdateServer.StandardInput.WriteLine("exit");
        }
コード例 #2
0
        public static void ServerUpdate(ArkServerInfo Server)
        {
            Process steamUpdateServer = new Process();

            steamUpdateServer.StartInfo.UseShellExecute        = false;
            steamUpdateServer.StartInfo.RedirectStandardInput  = true;
            steamUpdateServer.StartInfo.RedirectStandardOutput = true;
            //steamUpdateServer.StartInfo.CreateNoWindow = false;
            //steamUpdateServer.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            steamUpdateServer.EnableRaisingEvents = true;
            steamUpdateServer.StartInfo.FileName  = "cmd.exe";
            steamUpdateServer.Exited += (sender, e) =>
            {
                //Console.WriteLine(DateTime.Now + ": Process Complete for " + Server.Name + "    Time: {0} sec " +
                //"Exit code:    {1}", DateTime.Now.Second - steamUpdateServer.StartTime.Second, steamUpdateServer.ExitCode);
                Methods.Log(Server, DateTime.Now + ": Process Complete for " + Server.Name + " Time: " + (DateTime.Now.Second - steamUpdateServer.StartTime.Second) + " sec " +
                            "Exit code: " + steamUpdateServer.ExitCode);

                Server.CurrentlyUpdating = false;

                if (!Server.stopServerTimer)
                {
                    Server.GameUpdateNeeded = GlobalVariables.NeedsArkUpdate(Server);
                    Server.ModUpdateNeeded  = GlobalVariables.NeedsModUpdate(Server);
                }
                Methods.StartServerProcedure(Server);
                ((Process)sender).Dispose();
            };
            //Console.WriteLine(DateTime.Now + ": Running ServerUpdate method for " + Server.Name);
            Methods.Log(Server, DateTime.Now + ": Running ServerUpdate method for " + Server.Name);
            steamUpdateServer.Start();
            Server.CurrentlyUpdating = true;
            steamUpdateServer.StandardInput.WriteLine(GlobalVariables.SteamCMDCommand(Server));
            steamUpdateServer.StandardOutput.ReadToEndAsync();
            steamUpdateServer.StandardInput.WriteLine("exit");
        }
コード例 #3
0
        private static void CheckRoutine(object sender, EventArgs e)
        {
            //Run Server check
            foreach (var Server in Servers)
            {
                //Log that server is currently updating game files
                if (Server.CurrentlyUpdating)
                {
                    //Console.WriteLine(DateTime.Now + ": " + Server.Name + " is currently updating.");
                    Methods.Log(Server, DateTime.Now + ": " + Server.Name + " is currently updating.");
                }
                //If any event was triggered, or if the server is updating, do not run check routines.
                if (!Server.stopServerTimer && !Server.CurrentlyUpdating)
                {
                    //Console.WriteLine(DateTime.Now + ": Entered " + Server.Name + "'s check method. RunningTimer = " + nRunningEventsTriggered);
                    Methods.Log(Server, DateTime.Now + ": Entered " + Server.Name + "'s check method. RunningTimer = " + nRunningEventsTriggered);
                    bool processOpen        = GlobalVariables.IsProcessOpen(Server);
                    bool ServerIsResponding = RCONCommands.IsServerResponding(Server);

                    //Console.WriteLine("Server Response: " + ServerIsResponding);
                    Methods.Log(Server, "Server Response: " + ServerIsResponding);
                    Server.ModUpdateNeeded = GlobalVariables.NeedsModUpdate(Server);

                    //Console.WriteLine("Mods are up to date: " + !Server.ModUpdateNeeded);
                    Methods.Log(Server, DateTime.Now + ": Mods are up to date: " + !Server.ModUpdateNeeded);
                    Server.GameUpdateNeeded = GlobalVariables.NeedsArkUpdate(Server);

                    //Console.WriteLine("Game is up to date: " + !Server.GameUpdateNeeded);
                    Methods.Log(Server, DateTime.Now + ": Game are up to date: " + !Server.GameUpdateNeeded);

                    if (Server.ModUpdateNeeded && processOpen)
                    {
                        //Restart and Update the server if update is needed.
                        RestartProcedures.BroadCastArkUpdateRestartTimer(Server, "Mod Update: " + Server.theModNeedingUpdate);
                        Server.ModUpdateNeeded = false;
                        Server.stopServerTimer = true;
                    }
                    //If process is open and game needs to be updated, trigger restart counter
                    if (Server.GameUpdateNeeded && processOpen)
                    {
                        RestartProcedures.BroadCastArkUpdateRestartTimer(Server, "Ark Update");
                        Server.GameUpdateNeeded = false;
                        Server.stopServerTimer  = true;
                    }
                    if (processOpen && !ServerIsResponding)
                    {
                        if (Server.nEventsProcessOpenNotResponding == 10)
                        {
                            RestartUnresponsive(Server);
                        }
                        if (!Server.CurrentlyUpdating)
                        {
                            Server.nEventsProcessOpenNotResponding++;
                        }
                    }
                    if (nRunningEventsTriggered % 60 == 0)
                    {
                        string message = "25 TC Reward points for recruiting players. See Dicord for more information.";
                        Console.WriteLine(DateTime.Now + ": Message sent to " + Server.Name + " - " + message);
                        RCONCommands.GlobalNotification(Server, message);
                    }
                    //Run Game Version Update every 20 minutes
                    if (nRunningEventsTriggered % 20 == 0)
                    {
                        Processes.ModVersionUpdate(Server);
                    }
                    //If process is not running, AND timer is not stopped and server is not update then trigger the start routine.
                    if (!processOpen)
                    {
                        Methods.StartServerProcedure(Server);
                    }
                }
                //If the server has ran for 12 hours, trigger the routine maintenance restart.
                //if (nRagEventsTriggered % GlobalVariables.timeIntervalMaintenanceRestart == 0 && RagProcessOpen)
                //{
                //    ServerRestartForModORRoutineMaintenance(Ragnarok, "Routine Maintenance");
                //    RagnarokTimerTriggerStopped = true;
                //}
                //Backup the server every 2 hours.
                if (nRunningEventsTriggered % 30 == 0)
                {
                    Methods.BackupServerFiles(Server);
                }
            }
            nRunningEventsTriggered++;
        }