Dedicated Server Watchdog Program

Author Topic: Dedicated Server Watchdog Program  (Read 17787 times)

you dont need one, there is a SuperMacro program on the apple website that does a WAYY better job.
Is it called SuperMacro? I looked and couldn't find it.

No, don't make the program diagnose the crash, make the program copy the console.log, and append the date/time to the filename, so the server host can diagnose it.

windows.h?

If you can, make a version for Linux (major distributions, probably Ubuntu and others) and Mac? Some people host dedicated servers off Linux command lines and WINE, something like this would be helpful.

WINE should be able to convert the basic windows.h functions i'm using. It just converts the calls over. give me.... a second to test it in ubuntu... i'm not sure how it will act using a dos command space...

Edit:
Wine is not finding certain files required for monitoring the process. Right now I'm looking into each of those files to see what i can find. If it's as simple as including those files within the zip i'll just do that. Otherwise i'm looking into Coding and compiling a unix/linux version. I'm having trouble finding a comparable method to find a window handle.. which means i'll probably have to monitor it by its Process name.
« Last Edit: August 26, 2008, 04:58:19 PM by Poent »

Hm, looks good although I've never had that crashing problem and I host it straight from my computer.. If it ever starts to I'll use this though.

Have a cookie (Don't you just hate these?)  :cookie:

Thanks for the Cookie.
Here's the updated source. Will now check for "Frozen" servers as well.
I"m working on a cleaner version with a GUI, hopefully i'll be able to figure out how to make it a little more dynamic as well.

Also if someone has this running under WINE on and linux distro, let me know what missing files you have. Most of them are windows files that should be in system32 but have not yet been ported. Please list any other errors as well.

Code: [Select]
#include <windows.h>  // these are our preprocessors. Our API is defined here
#include <iostream>

using namespace std; //include the namespace lib. includes c functions (cout, cin)

STARTUPINFO          si = { sizeof(si) };   //This is a pointer to our "Start Up info" typedef
PROCESS_INFORMATION  pi;                    //This is a pointer to our process information (this is where we can grab the pid)
char                 szExe[] = "C:\\Program Files\\Blockland\\dedicated.bat";
HWND hwnd;
HANDLE phandle; //This is a typedef for the OpenProcess function
DWORD pid;   //this will store the PID of blockland.
DWORD result;
void info(); // Just moving the jibberish out of the way

int main(){
info(); //spits out our info and waits for the user
hwnd=FindWindow(0,"C:\\Program Files\\Blockland\\Blockland.exe");
if(hwnd){
GetWindowThreadProcessId(hwnd, &pid);
cout << endl << "the dedicated server is running under the PID:" << pid << endl;
cout << "Running Back checks..." << endl;
}
while(TRUE){
cout << "\nChecking if the server is up..." << endl;
hwnd=FindWindow(0,"C:\\Program Files\\Blockland\\Blockland.exe");
SendMessageTimeout(hwnd,WM_NULL,0,0,SMTO_BLOCK | SMTO_ABORTIFHUNG, 5000, &result);
if(!hwnd){
cout << "It appears that Blockland isn't up. Re-Launching...";
///*
CreateProcess(0, szExe, 0, 0, TRUE, 0, 0, 0, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
Sleep(2500);
hwnd=FindWindow(0,"C:\\Program Files\\Blockland\\Blockland.exe");
if(!hwnd){
MessageBox(0,"Unable to Re-Launch your dedicated server. Please make sure that you put this file into your BLOCKLAND folder",0,MB_OK);
break;
}
}
cout << endl << "Making sure it's not frozen..." << endl;
if(result){
cout << "It appears that Blockland is frozen running. Re-Launching...";
///*
CreateProcess(0, szExe, 0, 0, TRUE, 0, 0, 0, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
Sleep(2500);
hwnd=FindWindow(0,"C:\\Program Files\\Blockland\\Blockland.exe");
if(!hwnd){
MessageBox(0,"Unable to Re-Launch your dedicated server. Please make sure that you put this file into your BLOCKLAND folder",0,MB_OK);
break;
}
else{
GetWindowThreadProcessId(hwnd, &pid);
phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
cout << "\n your dedicated server has been succefully relaunched." << endl;
}
}
else{
cout << endl << "Check passed, everything is fine" << endl;
cout << "Currently the PID of the hooked blockland server is:" << pid << endl;
//*/

}
Sleep(30000);
}
CloseHandle(phandle);
return 0;
}

void info(){
cout << "Dedicated Server Watchdog Program" << endl;
cout << " Created for Blockland V9" << endl;
cout << " 8/24/08 - Version 1.0 " << endl;
cout << "By: Poent" << endl;
cout << "\n\nThis launcher was designed to work with Blockland stored in:\n C:\\Program Files\\Blockland" << endl;
cout << "You will be able to change this is later versions, \nbut until then... leave it there." << endl;
cout << "\n\n By default, this program will check every 30 seconds \nto make sure that blockland is running." << endl;
cout << "If for any reason the dedicated server is \nnot found, it will relaunch 'dedicated.bat' and verify \nthat it successfully relaunched." << endl;
cout << "\n\n The watchdog program is now ready to launch. \nOnce you're ready to begin, Simply hit 'Enter'..." << endl;
cin.get();
}

I tried loading this up in wine and I've only been able to launch it one way:
1. under terminal, run sudo WINE cmd.exe
2. navigate to your BL folder w/ DSWP in it
3. run DSWP from the terminal.

Once again, please report any missing files and errors here so that I can correct them.
« Last Edit: August 28, 2008, 11:48:28 PM by Poent »

Is it called SuperMacro? I looked and couldn't find it.
Is it called SuperMacro?

How do you install this?
pm me please

ZOMG GREAT!
I've been waiting...

Is it called SuperMacro?

I"m not sure, that's what Påndåñ said ti was called. I looked for a while and was only able to find a couple macro programs. All of them that seemed powerful enough had a pretty steep learning curve so I decided not to fuss with it.

How do you install this?
pm me please

The install instructions are included with the post. Just put the file here into the root of your Blockland folder. That will allow it to access everything it needs. I usually make a shortcut to it on my desktop just so I don't have to dig through the filesystem, so feel free to mess around with it. Mind you, it currently doesn't know how to read anything outside of the default blockland directory, so leave that specific alone.

Uhm I downloaded it to the right place but, when I launch it it says "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem."
and I reinstalled and the same thing comes up. :(

What operating system are you using?

If you're using windows then it sounds like your missing something from your system files. Make sure your system is up to date and that you have the latest versions of .net installed. If you're using something other than windows then you're pretty much on your own for now.

Im on windows XP, and I have no updates..

The most intelligent Person ont he site

Why?

He uses complete senteces lol

Im on windows XP, and I have no updates..

try downloading the .net framework... you shouldn't have too but it would at least help me cross out some of the problems. The latest version is 3.0, 3.5 if you want to use the beta release.

I'm still working on one for you unix users out there, hold tight.