Jump to content

Recommended Posts

Posted

realmd.sh :

file : realmd.sh

#!/bin/bash

if (ps -C mangos-realmd )

then echo "status : OK"

else

screen -d -m -S mangos_realmd while true; do nice -n 20 /opt/mangos/bin/mangos-realmd -c /opt/mangos/etc/realmd.conf; sleep 5; done

fi

I did and doesn´t work :(

and crontab:

# m h  dom mon dow   command
*/1 * * * * ./restarter.sh
*/1 * * * * ./realmd.sh

I have these scripts in main folder

  • Replies 64
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Script for realmd

file : restarter_realmd.sh

#!/bin/bash

if (ps -C mangos-realmd )
   then echo "status : OK"
else
       echo "status : DOWN" 
       cd PATH_TO_YOUR_MANGOS/bin


       screen -d -m -S session_name PATH_TO_YOUR_MANGOS/bin/mangos-realmd
fi

in your crontab you should use absolute paths, ti avoid errors.

Depending on the user's crontab the "./" fodler could be his home directory , or /root ...

Is restarter for mangos working ?

Posted
yes I need help, any of this scripts that u and perunio said me doesn´t work.. I don´t know why :(

The scripts work, you're doing something wrong, paste your crontab file again, and the output from manually running the restarter.

Posted

mangos:

file : restarter.sh

#!/bin/bash

if (ps -C mangos-worldd )
   then echo "status : OK"
else
       echo "status : DOWN"
       cd /opt/mangos/bin

       tar -czvf logs.tar.gz Server.log DBErrors.log Char.log

       #enable crashdumps
       ulimit -c unlimited

       screen -d -m -S mangos cd /opt/mangos/bin && while :; do ./mangos-worldd; done
fi

realmd:

file : restarter_realmd.sh

#!/bin/bash

if (ps -C mangos-worldd )
   then echo "status : OK"
else
       echo "status : DOWN"
       cd /opt/mangos/bin


       screen -d -m -S mangos_realmd /opt/mangos/bin/mangos-realmd
fi

crontab:

 m h  dom mon dow   command
*/1 * * * * cd /home; ./restarter.sh
*/1 * * * * cd /home; ./restarter_realmd.sh

Posted

Once again you need to input the full path so in this case I think it's something like

* * * * * /home/USERNAME_HERE/restarter.sh

Replace USERNAME_HERE with your username in linux.

Posted

Except full pathes,

your crontab seems to be ok. Try to launch the restarter.sh manually, and tell us what's going on.

You may have a problem with the rights of the user running the crontable, check you have the rights to execute mangos with the crontab's user

Posted

I have it in home folder, not in my user folder..I see it in FTPclient in home.. but if I want start it.. it wrote...

dark@serverwow:/home$ sudo ./restarter.sh

sudo: ./restarter.sh: command not found

Posted

I don´t know.. but in realmd it does:

dark@serverwow:/home$ sudo sh restarter_realmd.sh

: not foundealmd.sh: 2:

PID TTY TIME CMD

and when I want connect it writes connecting..then this doesn´t work

Posted

Oy vey...

You have two approaches here. Mine is to start up mangos as it's brought up along with a boot of your OS. The other is to check periodically whether the server is running via cron(1) and to start it if it isn't. Both scripts are rather a simpleton in their own way, since the startup script doesn't handle taking the application down, nor does it care about it after it's attempted to start. Kind of a fire-and-forget approach, but it's well... Simple. The cron(1) based approach checks to see whether a process exists with its zeroeth argument matching 'mangos-worldd'. Neither are fool-proof, but good enough to get you started.

Alas, I'd rewrite the cron(1) based approach slightly:

pgrep 'mangos-worldd'
if [ $? = 0 ]
then
       echo "status : OK"
else
       echo "status : DOWN"
       screen -d -m -S world /opt/mangos/bin/mangos-worldd
fi

This way you aren't dependent on string evaluations and you don't need to throw output in the bit bucket. Also you don't need to worry about unary operators screwing you over. Hope this works for you.

Posted

I prefer using this script with cron as it's easily configurable and expandable (Written by me)

#!/usr/bin/env python

import commands
import os
from sys import exit

# exit()

config = {
   'servername' : 'servername',   # Name of the wow server (Prefix for the screen session)
   'user' : 'username',         # User that should run the server processes
}

# List of processes that should be checked periodically
daemons = {
   'logon' : '/path/to/mangos-realmd',
   'realmname' : '/path/to/mangos-worldd'
}

for name, path in daemons.iteritems():
   if not path in commands.getoutput('ps -Af'):
       os.chdir(os.path.dirname(path))
       os.system('screen -A -m -d -S ' + config['servername'] + '_' + name + ' sudo -u ' + config['user'] + ' ' + path)
       print '[Restarter] Starting ' + name
   else:
       print '[Restarter]', name, 'is already running'

Configure it add it to cron and you're ready to go.

Posted

WOALA! IT WORKS, btw perunio.. that rc doesn´t work

and ... when I did cd /opt/mangos/bin && while :; do ./mangos-worldd; done it restarted immidiately

can this script restart immidiately ?

Posted

but I have great server..my mangos gets started in 3seconds..then minute is too long time

btw perunio ..how add that code, that will start when linux start...rc doesn´t work

or how add ur commands to crontable.. it will start at launch of mangos and reseting immediatelly after crash ?

Posted

The biggest issue around is that the MaNGOS daemons aren't fork() and detach, but rather they stay in the foreground. This makes it less clever to put into init scripts and you have to play games with nohup(1) and detach them yourself from the controlling terminal. That said, it isn't necessary to rely on cron to restart the executable if it fails. One could do something akin to the while(1) loop described above, but perhaps with a little delay just in case you don't want to clobber your system in a tight loop fashion in case there's a problem. Something like inserting a sleep(1) at the end of the first nest. Ubuntu comes with an init-style restarter called Upstart and its actually good at understanding whether a process died. This is how I manage my servers and I find it more versatile. But its pretty implementation specific and not a great way to learn how to script and manage systems. Granted, this probably wasn't your goal anyway. :)

Posted
then help me with ur way step by step :(

What about you trying to find something yourself? Seriously, your questions and errors here belong to person with IQ below 50. I've suggested the rc.local way (which would work on OS startup as well), perunio here provided the simpliest working process restarter ever, xeross supplied his python script, so I'd simply choose one way and try my best with it. Google included.

Simply said - run the small loop (with added sleep delay) in a screen session started by rc.local. That's it. No need for PID lookups, no need for every-minute checks.

  • 2 months later...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use