PDA

View Full Version : Autorestart for MOHAA?


GrungeMan
10-30-2002, 06:51 PM
Is there any progg that restarts a moh server after it crashes if the server is hosted by a person and not a gameserver provider?

Would be nice to have, cuz then it would restart if im not at home and the server crashes :D

DogMeat
10-31-2002, 10:20 PM
Depends on what OS your using, here's an old batch file I came up with for Windows, it will do some basic backups on your logs and continually run MoHAA, restarting it after a crash or exit.
[code:1]@echo off
echo DogMeat's NeverEnding MoHAA
:TOP
echo Backing up Log
cd main
copy qconsole.lo1 *.lo2
copy qconsole.lo0 *.lo1
copy qconsole.log *.lo0
cd ..
echo Starting MoHAA
start /wait MOHAA_server.exe +set ui_console 1 +set dedicated 1 +set cheats 0 +set developer 1 +exec servertfo.cfg
echo Restarting
goto TOP[/code:1]

I'd post my current Linux shell scripts, I've got a ton to add to them but they work. Unfortunately I can't access that partition on my Linux box right now, have to finish my Red Hat install.

ThePlagueofDeath
10-31-2002, 11:24 PM
If you dont mind, when you get redhat installed, can ya post em, or E-Mail em to me? My server is ran at my ISP, and of course they dont want to give me shell access (I wonder why, LOL), But If the server crashes, like today, I have to wait until the morning when they open up to get them to restart the server. This would help me out alot.

theplagueofdeath@tisd.net

Thanks
M [84thUSMC] Plague of Death

DogMeat
11-01-2002, 02:52 AM
LINUX SHELL SCRIPTS
(not windows!)

As I mentioned before, there are alot of things I want to add to these, mostly dealing with logs and detecting a "killfile". However in their current state they are rocksolid and don't do anything that would give your provider a reason not to implement them, such as run 3rd party programs.

Be sure and change the directories and commandline options for the mohaa server to what YOU need.

The first one is a simple loader script which uses SCREEN to place the MoHAA server on a detached console. Copy and paste into a file called mload.sh and chmod it 755.
[code:1]#!/bin/bash

echo mload.sh: Load MoHAA With Screen

cd /lfs/game/mohaa

echo mload.sh: Screen Mohaa Detached Console

screen -S mohaa -m -d ./mlds.sh

echo mload.sh: Finished Screen Command[/code:1]
Next is the actual looping script itself, this can of course be used standalone without using mload.sh, but then you lose the benefits of SCREEN. Copy and paste into a file called mlds.sh and chmod it 755.
[code:1]#!/bin/bash

echo mlds.sh: Launching Mohaa

cd /lfs/game/mohaa

echo mlds.sh: Loop Initialize
while true
do
echo mlds.sh: Loop Start
echo mlds.sh: To Exit Loop Hit CTRL-C While Sleeping
sleep 5
echo mlds.sh: Server Start
./mohaa_lnxded +set sv_chatter 1 +set developer 1 +exec servertest.cfg
echo mlds.sh: Server Exit
echo mlds.sh: To Exit Loop Hit CTRL-C While Sleeping
echo mlds.sh: Sleep 15 Seconds
sleep 15
echo mlds.sh: Loop Restart
done[/code:1]
Hope this helps, I'll post any future enhancements to the scripts here also.

GrungeMan
11-01-2002, 09:34 AM
Great! thx! :D

I'll try it today :D

11-01-2002, 02:36 PM
Dogmeat, I would love to post these in the download section when you finish them.

Thanks for all your help. I know between you, crowking and a couple of others. The MOH community is much better.

GrungeMan
11-01-2002, 05:41 PM
I tried it and it works great, however, it doesn't seem to log the server like it should, but i'll think ill fix that. Great help, thanks yet again! :D

DogMeat
11-02-2002, 08:15 AM
GM: If your talking about Windows, make sure this line section is all on ONE line, not two. For logging to work developer needs to be set to 1, and if you set it at 2 you get more player command info. (like showing attempts to use the "sub crash")

start /wait MOHAA_server.exe +set ui_console 1 +set dedicated 1 +set cheats 0 +set developer 1 +exec servertfo.cfg

If your talking about Linux, look for a /.mohaa/main/qconsole.log under the home dir of the user running the mohaa server.

RD: It'd probably be best to put this one up as the basic Linux script, and then add the others as more advanced versions. Plus not everyone will need all the pieces I'm going to be adding, and with a progression of scripts it'll be easier for them to learn and customize if needed. If you would please include my standard "free to use" & "name and website" text on the guides when you compile it.

This first script set is especially important because of it's simplicity, even novice linux admins can get it up and running and no server provider should object to the script or it's methods. Many new admins don't realize the secret power that an automatic restart script gives you, so those that do get to nod sagely while I discourse thereupon. ;)

rcon quit

So we just exited our server, script runs sleeps loops and reloads the server again, ok so it works, so what... Well lets take a small step backwards, to what we did before giving the quit command. First we took a couple of maps we'd been trying out locally and FTP'd 'em to our directory on the game server. In order to get the server to load our new pak files we've of course got to completely restart the engine from scratch, which thanks to our simple script we can do at will and have the server up and accepting clients again in a minute. (I timed my 333Mhz RedHat system under X/Gnome: after a quit cmd it took 67 seconds before it was again responding to client requests, even with the built in 20 seconds sleep)

While some server providers have the web interfaces kicking, many more admins seem to be in an "email wait til tommorrow" situation.
Hopefully this will help get some folks out of that rut. xmas

11-02-2002, 09:16 AM
Guide added,
I called it DogMeat's keep alive Linux Script , Let me know if I should rename it.

Thanks DM another job well done.

DogMeat
11-03-2002, 01:00 AM
RD I'll grab what you've got up now and make a few changes to it, but what's there is great until I can get around to it. ;)

Primal
05-07-2003, 06:49 AM
Will this work for SH?
& a silly question im sure, what dir do I upload them to?

GrungeMan
05-07-2003, 07:03 AM
Well you should have it in the MOHAA folder, but it doesnt work with SH, the server rarely restarts if it crashes, but it makes backup copies of the log file, thats nice ;)

Maverick
06-03-2003, 08:25 AM
Hey all, the scripts above will work fine with Spearhead to do a normal restart (i.e. admin doing an rcon quit). You're right that if a Spearhead server crashes it usually hangs and doesn't exit. For that occasion, I put together a script for ClansElite that will simply look for a file to be FTPed and when if finds that file it does a ps to get the process of all running servers and kills them. After that, the above script will restart the server nicely. :)

If anyone is interested in said script, just let me know and I'll post it.

FredG
06-05-2003, 11:16 AM
I'd love to have a look at that script Mav if you wouldn't mind posting or pm it to me. :)

Maverick
06-05-2003, 12:13 PM
Ok, here it is. I'll recap at the bottom what it does, just in case there are non-script ppl reading it. :D

echo killserver.sh: Loop Initialize

while true
do
echo killserver.sh: Loop Start
echo killserver.sh: Looking for file
if [ -f killit ]; then
echo killserver.sh: File found, killing servers
echo killserver.sh: Killing each server
# Second loop that will kill all instances of the server
# Change spearhead to appropriate value for MOHAA
while [ `ps -ef | grep $USER | grep spearhead_lnxded | grep -v grep | wc -l` != 0 ]
do
# Find the process number for the server
# Change spearhead to appropriate value for MOHAA server
PROCNUM=`ps -ef | grep $USER | grep spearhead_lnxded | grep -v -m 1 grep | cut -c9-14`
# echo $PROCNUM
# Kill the server process. Restart script will pick up from there and restart the server
`kill -9 $PROCNUM`
done
# All server processes should now be gone
echo killserver.sh Servers killed!;
# Get rid of the tigger file
rm killit
fi
echo killserver.sh: Sleeping 1 minute
# Sleep for 1 minute and look for the file again
sleep 60
done

The basic jist is that this will run forever, sleeping for 1 min, wake up and look for a file called killit in the home directory of the user that ran it. If it finds the files, it goes out and gets the process number of every spearhead server running for that usuer and kills each one individually. Then it removes the killit files and goes back to sleep.

If you use this in conjunction with the scripts above, then the restart script above will take care of restarting the killed server. For the restart script above to work with Spearhead, just change the mlds.sh to start your Spearhead server instead of MOHAA.

Let me know if you have any questions on it.

barf
06-08-2003, 03:54 AM
Hey i have a linux 7.2 box and added the KAL scsript to my MOHAA folder. Chmod to 755 and added my launching info. Wont restart the server. Please help heres the files :

Heres mload.sh:

#!/bin/bash

echo mload.sh: Load MoHAA With Screen

cd /home/virtual/cudasystems.com/MOHAA/

echo mload.sh: Screen Mohaa Detached Console

screen -S MOHAA -m -d ./mlds.sh

echo mload.sh: Finished Screen Command


Heres mlds.sh:

#!/bin/bash

echo mlds.sh: Launching Mohaa

cd /home/virtual/cudasystems.com/MOHAA/

echo mlds.sh: Loop Initialize
while true
do
echo mlds.sh: Loop Start
echo mlds.sh: To Exit Loop Hit CTRL-C While Sleeping
sleep 5
echo mlds.sh: Server Start
./mohaa_lnxded +set dedicated 1 +exec mixedObjTdm.cfg
echo mlds.sh: Server Exit
echo mlds.sh: To Exit Loop Hit CTRL-C While Sleeping
echo mlds.sh: Sleep 15 Seconds
sleep 15
echo mlds.sh: Loop Restart
done

IM STUMPED PLEASE HELP! 8O

Maverick
06-08-2003, 06:38 AM
The problem is you're recursing. The mlds.sh is actually supposed to START the MOHAA server (mohaa_lnxded). The way you changed the file all mlds.sh does is call itself, so the server is never actually started. You also don't need a screen command in mlds.sh, it's already been done in mload.sh. See the original script above for the example of the mlds.sh that works.

barf
06-08-2003, 01:34 PM
I pasted the same .sh file twice ....lol I fixed it so please review it again...LMAO. Thanks 8O :twisted:

Maverick
06-08-2003, 02:14 PM
What exactly is it doing? What you have should be fine. You say "it won't restart the server". Does it start the server once or not at all? Are you doing an rcon quit and it doesn't restart? You may want to add the +ui_console 1 to the command line, and I assume you have info about the server name, IP, etc. in the cfg file? You're going to have to give me some more info like any return codes or anything you're getting.

barf
06-08-2003, 02:57 PM
Its not doing shit man. I have the correct .cfg yes it fine ive been running it for awhile now. Cant understand what the deal is ... the only thing maybe the files were uploaded ROOT to the MOHAA directory.. I set permissions right and everything else seems cool...? Cant figure it out.


I uploaded the .sh files
started the server with putty "a ssh program"
went in to the game
joined the game
rcon quit
serevr shut down
Waited for the script------nothing happens

Maverick
06-09-2003, 09:20 PM
So when you start the script using mload.sh, the script starts up and you see it running? Do a ps -ef | grep (your user id) on the system and make sure it's up. Do the rcon quit, and then do the ps again. You should see sleep running since it sleeps for 20 sec before restarting. After 20-30 seconds do the ps again and you should see the mohaa_lnxded running again. Beyond that, I'm not sure. It's almost like you're not starting the server with a script... I'm stumped...

FredG
06-09-2003, 10:55 PM
not to turn this away form your issues barf, but I have a question for anybody out there who may have the shell skills. Is there anyway to this thing write the pid of A. the screen and B. the actual server instance to a pid file. This would allow the server instance to be more accurately killed for us people running multiple server instances. Sometimes you don't want to just grep and kill all the mohaa_lnxded that are running. But if the pid could be wrote to an identifiable pid file then you could kill |cat pidfile.name and get the right one.

if any shell scripters would be interested in this but need more info on what I'm talking about shoot me a pm. I know exactly what it needs to do, I just don't have the shell experience to code it.

Tuding
06-22-2003, 06:18 AM
abit of a dumbass me but do i open notepad make the mload and then save it a sh file?

FredG
06-22-2003, 12:10 PM
yes...
or to be more sure that your text editor is not adding hidden characters to the file (which could cause problems) create the file on your linux system with pico or vi by copy pasting the code. If you use pico make sure you create the file with a pico -w (so line wraps don't mess you up either).

Tuding
06-22-2003, 12:12 PM
thx mate

MaSSivE
07-19-2003, 03:23 PM
nice script dogmeat, but u got that to for windows? i'm hosting servers on windows 2003 and i need a quit script voor mohaa. I hope u got that

greetz massive

Pavak
02-21-2004, 12:28 AM
This is my first post ever, and now im feeling a little less nolagable than i thought i was. well here is what im trying to do, and what is here is very nice, just im looking for a little more and a little more explenation... ok here goes
I have 3 MOH SpearHead servers running I want to be able to stop and start each one seperatly, but if one of them locks up i want to be able to kill the process. I am willing to have multiple batch files on for each of the servers if i must. I have some MOD's that i test that seem to kill the servers some times. I would like to set a WEB page on my server so that i can run a .BAT file to kill and then start a server. that would make things realy easy for me.

Thanks for your time
Pavak

Always trying to look bigger than i realy am...

TheDaddy2003
03-08-2004, 05:55 AM
Hey i have a linux 7.2 box and added the KAL scsript to my MOHAA folder. Chmod to 755 and added my launching info. Wont restart the server. Please help heres the files :

Heres mload.sh:

#!/bin/bash

echo mload.sh: Load MoHAA With Screen

cd /home/virtual/cudasystems.com/MOHAA/

echo mload.sh: Screen Mohaa Detached Console

screen -S MOHAA -m -d ./mlds.sh

echo mload.sh: Finished Screen Command


Heres mlds.sh:

#!/bin/bash

echo mlds.sh: Launching Mohaa

cd /home/virtual/cudasystems.com/MOHAA/

echo mlds.sh: Loop Initialize
while true
do
echo mlds.sh: Loop Start
echo mlds.sh: To Exit Loop Hit CTRL-C While Sleeping
sleep 5
echo mlds.sh: Server Start
./mohaa_lnxded +set dedicated 1 +exec mixedObjTdm.cfg
echo mlds.sh: Server Exit
echo mlds.sh: To Exit Loop Hit CTRL-C While Sleeping
echo mlds.sh: Sleep 15 Seconds
sleep 15
echo mlds.sh: Loop Restart
done

IM STUMPED PLEASE HELP! 8O

Judging from that script i think the problem is hes not calling for the mlds.sh script from mload.sh

starting with mload.sh

#!/bin/bash

echo mload.sh: Load MoHAA With Screen

cd /home/virtual/cudasystems.com/MOHAA/

hes calling from this directory to load mlds.sh while this file is actually in the same dir as mload.sh

i think for complete noobs you need to adjust the guide, myself being a complete noob followed the guide exactly took me best part of 2 hours to realise this simple mistake.

yestarday i didnt no what SSH was now ive managed to ftp MOH and load it and install your restart script.
I have to say your guides are excellent couldnt of got there without it, but remeber those that read those guides are most likely complete noobs with no knowledge of the commands or how things work :P

nice one everyone and welldone for helping the community out Rude you run excellent websites.

Mad_MAX
05-08-2004, 11:50 AM
Hello!!

Please can you send me or show me where can i download this scripts for linux mohaa server . I`m green on linux and i dont know how to do it :)

Please.

SNYPE
05-09-2004, 04:26 PM
Dogmeats Linux script is in our Guides section:
http://www.mohadmin.com/2004light/index.php?tim=&cat_id=Guides

Mad_MAX
05-18-2004, 05:11 PM
Blah!! :((

But this is only a code for script.

Im lookin for "script"-file. Im lame in linux and i dont know how to install it or how to write it. I know that it is all here but i dont know how to do it.

Hehe.

aftermathgamers
08-05-2004, 11:57 AM
not to turn this away form your issues barf, but I have a question for anybody out there who may have the shell skills. Is there anyway to this thing write the pid of A. the screen and B. the actual server instance to a pid file. This would allow the server instance to be more accurately killed for us people running multiple server instances. Sometimes you don't want to just grep and kill all the mohaa_lnxded that are running. But if the pid could be wrote to an identifiable pid file then you could kill |cat pidfile.name and get the right one.

if any shell scripters would be interested in this but need more info on what I'm talking about shoot me a pm. I know exactly what it needs to do, I just don't have the shell experience to code it.

did you ever get the info on this? thats excatly what i been looking for :)

IZZO
08-16-2004, 08:16 PM
how would i get this to work on bt demo and what find of file does this go in to a .cfg?? and i am useing windows server 2000

SNYPE
08-17-2004, 08:41 AM
how would i get this to work on bt demo and what find of file does this go in to a .cfg?? and i am useing windows server 2000
This thread applies to Linux servers. If you want to be able to restart a Windows server you would need to use a program like FireDaemon (http://www.firedaemon.com/) that can run the game as a Service.

aftermathgamers
08-17-2004, 10:04 AM
Theres a great new Free control panel that can do all that for you at www.GamePanel.org .. if anyone ever finds me a free linux web based control panel on linux for MOHAA spearhead among other games, ill give ye a free server :D

gorillaman
08-25-2004, 04:31 AM
Theres a great new Free control panel that can do all that for you at www.GamePanel.org .. if anyone ever finds me a free linux web based control panel on linux for MOHAA spearhead among other games, ill give ye a free server :D

Ok, here is a free linux control panel for MOH series, I wrote this myself:
http://www.3dgorilla.com/files/game_server.zip

:)

Lamron
08-29-2004, 01:58 PM
Here is what I'm trying to use. Obviously its DogMeat's script without the logging and ~converted for Spearhead.


@echo off
echo DogMeat's NeverEnding MoHAA
:TOP
echo Starting MoHAA
start /wait moh_spearhead.exe +set dedicated 1 +exec serverstart.cfg
echo Restarting
goto TOP


This is for Windows XP and the above file name is from the shortcut I use to start the server. I have that script in a .bat file and when I exec it I get a Windows error:

Launch MFC Application has encountered a problem and needs to close.

The error says that the problem is: AppName: configure_spearhead.exe

That .exe shouldn't even be trying to run, so I can't figure out what the problem is. Does anyone have a working example written for Spearhead that I could use?

GaSplat
08-29-2004, 06:18 PM
You just need to start the dedicated server program instead of the game client.

@echo off
echo DogMeat's NeverEnding MoHAA
:TOP
echo Starting MoHAA
start /wait moh_spearhead_server.exe +set dedicated 1 +exec serverstart.cfg
echo Restarting
goto TOP

Lamron
08-29-2004, 06:43 PM
I tried that, and it just claims that it can't find moh_spearhead_server.exe (the file really is there and working).

I can script for the game, but I don't have any experience with .bat files. Do I need to tell it what drive to look in? I have it installed in E. Maybe its looking in C?

IZZO
08-30-2004, 07:43 AM
as long as its in the folder that the moh_spearhead_server.exe is in then it should work it does for me then i just make a shortcut to the .bat file and put it in a easyer place to get to

Lamron
08-30-2004, 09:04 PM
LOL Thank You! I'm sure its obvious to anyone used to working with batch files, but I didn't know it had to be in the same folder to work. Now it works.

Nat_Greene
12-05-2006, 01:42 PM
Hi,

I understand that the code below is a log backup feature, but could someone explain to me exactly what it's doing? It appears to make 2 backups of the qconsole log in the main directory. :confused: I don't understand what the qconsole suffixes are, i.e. qconsole.lo1*.lo2.

Thanks.


copy qconsole.lo1 *.lo2
copy qconsole.lo0 *.lo1
copy qconsole.log *.lo0

GaSplat
12-06-2006, 12:12 AM
They are basically keeping the last three versions of the log, as well as the current log. This way a recurring problem can be seen from mulitiple logs.

The current log is qconsole.log. The one from the last restart is qconsole.lo0. The one from two restarts ago is qconsole.lo1, and three restarts ago is saved as qconsole.lo2. This last one wil be overwritten and lost on the next restart. On each restart, each log replaces its predecessor so you always have the current log and the logs from the last three starts.

Hope that clarifies.

Nat_Greene
12-06-2006, 10:46 AM
Hey GaSplat,

Thanks for your usual quick response! That clarifies it. :D