Alde. (05-12-2013),Goodfeet (05-15-2014),lkdjnfoskjednfblksjdfn (09-22-2015),TynanM (05-13-2013)
This is a very simplistic method you can use to make your own restarter.
You'll notice that when the web server chashes, instead of closing, windows fault detection kicks in and prompts the user for "advice".
This is WerFault.exe. If we run a method that detects it running, we can then close it, and execute our server again.
Now obviously this method will only check and restart ONCE. We need to call it every few seconds so it will check every few seconds.Code:Process[] prs = Process.GetProcesses(); //use the windows API to get an array of current processes on the local machine. foreach (Process pr in prs) { if (pr.ProcessName == "WerFault") //for each process there is, if its name is "WerFault" then... { pr.Kill(); //KILL IT! Process.Start(@"C:\PooperScooper\bin\wServer.exe"); //Then start wServer again, in the ""s put your path to wServer } }
A simple way to do is is by creating a new timer on your form or in your console app and for the "tick" event for your timer put the code above.
(for windows form users, you can drag a timer from the toolbox in visual studio, doubleclick it and you'll be brought to an auto-generaterated event handler for your timer called "timer_tick". Inside the brackets put the code above.)
EXAMPLE:
DON'T FORGET TO START YOUR TIMER!Code:private void timer1_Tick(object sender, EventArgs e) { // PASTE THE CODE: Process[] prs = Process.GetProcesses(); //use the windows API to get an array of current processes on the local machine. foreach (Process pr in prs) { if (pr.ProcessName == "WerFault") //for each process there is, if its name is "WerFault" then... { pr.Kill(); //KILL IT! Process.Start(@"C:\PooperScooper\bin\wServer.exe"); //Then start wServer again, in the ""s put your path to wServer } } }
Example being having a button, that when pressed, calls timer1.Start();
yeah this isn't the best tut but it will help a few people for sure
have fun!
Last edited by krazyshank; 05-12-2013 at 01:35 PM.
Alde. (05-12-2013),Goodfeet (05-15-2014),lkdjnfoskjednfblksjdfn (09-22-2015),TynanM (05-13-2013)
Whrn i use your Krazy Pserver, when it crashes it auto restarts. Is this for older versions of your pservers?
Also, when it crashes nothing comes up. At least on my 2 laptops.
Small question forgot about this, but when i try to use your KrazyServer2 Item Spawner, it brings up something like "the specified program "Adobeflashblahblahblah" could not be found. The Spawner is not compatible with anything else. Just wondering how to fix it.
Edit: Also i get it now @Abovecomments
Last edited by MasterFart; 05-11-2013 at 09:18 PM.
Sorry. i thought it was just a quick question. :/
Not bad Krazy, try doing one that attaches to teh process as a virtual debugger and watch for exceptions that are not catcher .net has a built in library for it
Old thread? all process.blah the process gives me an error
Hrm, when i use it, after wserver crashes it goes totally chaotic and opens tons and tons of wservers and giving me an unknown error or something.
Code:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Diagnostics; namespace Auto_Restart_wServer { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void timer1_Tick(object sender, EventArgs e) { // PASTE THE CODE: Process[] prs = Process.GetProcesses(); //use the windows API to get an array of current processes on the local machine. foreach (Process pr in prs) { if (pr.ProcessName == "WerFault") //for each process there is, if its name is "WerFault" then... { pr.Kill(); //KILL IT! Process.Start(@"C:\Users\Raymond\Desktop\REALM OF THE MAD GOD\Clean Server Files\rotmg_svr-master\wServer\bin\Release\wServer.exe"); //Then start wServer again, in the ""s put your path to wServer } } } private void button1_Click(object sender, EventArgs e) { timer1.Start(); } } }
Goodfeet (05-15-2014)
HELP ME I DONT KNOW HOW TO GET THIS PSERVER RUNNING
BlackRayquaza (02-07-2015)