Auto Restart

02/17/2010 07:21 5supertao#1
can someone give me a code to restart the server every 2 1/2 hours.
02/17/2010 07:37 xSynthesis#2
Go to Program.cs and search for

PHP Code:
Database.LoadLottoItems(); 
Then add these under it
PHP Code:
                Program.WriteLine();
                
Program.RestartTimer = new System.Timers.Timer();
                
Program.RestartTimer.Interval = (120 60000);
                
Program.RestartTimer.Elapsed += new System.Timers.ElapsedEventHandler(Program.Restart);
                
Program.RestartTimer.Start();
                
Program.RestartTimer1 = new System.Timers.Timer();
                
Program.RestartTimer1.Interval = (10 60000);
                
Program.RestartTimer1.Elapsed += new System.Timers.ElapsedEventHandler(Program.Restart1);
                
Program.RestartTimer1.Start();
                
Program.WriteLine("Server restart timer ON"); 

Then add these voids

PHP Code:
        public static void Restart1(object sourceSystem.Timers.ElapsedEventArgs e)
        {
            
Program.WriteLine("Server will restart in 10 min");
            
Game.World.SendMsgToAll("Server""Server will restart in 10 minitues. Please log off to avoid data loses"20010);
          
        }
        public static 
void Restart(object sourceSystem.Timers.ElapsedEventArgs e)
        {

            
NewestCOServer.Main.AuthWorker.Listener.Close();
            
NewestCOServer.Main.GameWorker.Listener.Close();
            try
            {
                foreach (
Game.Character C in Game.World.H_Chars.Values)
                {
                    try
                    {
                        
C.MyClient.Disconnect();
                        
Console.WriteLine(C.Name " has logged off successfuly.");
                    }
                    catch { continue; }
                }
            }
            catch { }
            
Database.SaveKOs();
            
Console.WriteLine("KOs saved.");
            
Database.SaveEmpire();
            
Console.WriteLine("Empire saved.");
            
Features.Guilds.SaveGuilds();
            
Console.WriteLine("Guilds saved.");
            
Features.SkillsClass.Save();
            
Console.WriteLine("Skills saved.");
            
Console.WriteLine("Database disposed.");
            
Console.WriteLine("Write /exit or click X to close the window.");
            
System.Diagnostics.Process.Start("NewestCOServer.exe");
            
Environment.Exit(0);
        }
    }


That will restart your server every 2 hours.
04/08/2010 00:35 pintser#3
what is the defenition for : RestartTimer?
(in Database ore ProgramCs.?
04/08/2010 00:36 zTREME#4
doing it hard :)
Make a simple timer for it and a methode then your done :)
04/08/2010 00:42 pintser#5
u following my posts :p...
04/08/2010 04:44 LetterX#6
Why make 2 Timers? Why not make just one, and then call the other void (or merge them into one large one)? D:

More efficient in my opinion...but then again...if a server needs to be restarted automatically...it's not so efficient to begin with. x.x
04/08/2010 14:46 zTREME#7
Quote:
Originally Posted by LetterX View Post
Why make 2 Timers? Why not make just one, and then call the other void (or merge them into one large one)? D:

More efficient in my opinion...but then again...if a server needs to be restarted automatically...it's not so efficient to begin with. x.x
dats what i said.
Just make a simple timer and a methode ^^
04/09/2010 03:32 PeTe Ninja#8
.. what source?
04/09/2010 21:52 Jăy1029#9
@PeTe
5165

@Synthesis
I dont think thats 2 1/2 hours cause my server just retarted, I think it was 20-25 mins or so. what would i change the "120" to to make it 2.5 hours? >.>
04/09/2010 22:28 zTREME#10
Quote:
Originally Posted by Jăy1029 View Post
@PeTe
5165

@Synthesis
I dont think thats 2 1/2 hours cause my server just retarted, I think it was 20-25 mins or so. what would i change the "120" to to make it 2.5 hours? >.>
change 60000 :D
04/12/2010 18:21 pintser#11
This aint working for my source..
bcs i dont have defenition of RestartTimer

but in most basic sources, there is a auto-restarter,
in program cs if i am right..

where to put this 1 exactly, ttried to run it sometimes, but no luck :(
04/12/2010 18:38 ~Yuki~#12
public static System.Timers.Timer RestartTimer = new System.Timers.Timer();