Jump to content

MaNGOS Restarter ?

Guest Darkhunter

Recommended Posts

  • Replies 64
  • Created
  • Last Reply

Top Posters In This Topic

Currently I have this python script

#! /usr/bin/python

import commands
import os
from sys import exit

# exit()

servername = 'mangos'

daemons = {
   'logon' : '/path/to/mangos/mangos-realmd',
   'world' : '/path/to/mangos/mangos-worldd'

for name, path in daemons.iteritems():
   if not os.path.basename(path) in commands.getoutput('ps -A'):
       os.system('screen -A -m -d -S ' + servername + '_' + name + '  sudo -u mangos_user ./' + os.path.basename(path))
       print 'Starting ' + name
       print name + ' is already running'

together with this cron job

  * *  *   *   *     python /path/to/restarter.py

Link to comment
Share on other sites

I see. No you don't need to add anything to /etc/rc.local, you could just drop your script into /etc/init.d. Call it `mangos' or something. Then in /etc/rc2.d, /etc/rc3.d and /etc/rc5.d create a symbolic link to it called `S99mangos'. The capital 'S' is important because it implies that you want to start the service. The number is an integer which defines in which order you want to run the script. Probably safe to run it at the 99th iteration as you need the system up and running anyway.

Link to comment
Share on other sites

I created file .py copied your script and change paths..saved it.. wrote in console:

[email protected]:~$    * *  *   *   *    python mangos.py
DBErrors.log: command not found

It is a cronjob not a bash command, and the way you tried to call it tells me you don't understand what you're doing tbh.

First of you need to edit the script so that it runs under the preferred user and uses the correct paths (I will make it easier to configure), after that you add that line I told you to your crontab file using "crontab -e" and of course correctly insert the path

Link to comment
Share on other sites

Alright, I see where this needs to go. First, you'll need a script with which to start your daemons:


cd /opt/mangos/bin
nohup ./mangos-realmd > /dev/null 2>&1
nohup ./mangos-worldd > /dev/null 2>&1

Then you need to copy said script (assuming it's called `mangos') to /etc/init.d:

sudo cp mangos /etc/init.d

After which you need to ensure that it is indeed able to execute, so set the least-most bit on the owner:

sudo chmod +x /etc/init.d/mangos

When this is done, you can use a handy wrapper present in Ubuntu to create the requisite links:

sudo update-rc.d mangos start 99 S .

That should do it.

Link to comment
Share on other sites

You can create a restarter with a few lines of bash

file : restarter.sh


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

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

       #enable crashdumps
       ulimit -c unlimited

       screen -d -m -S session_name PATH_TO_YOUR_MANGOS/bin/mangos-worldd

and execute this script using cron

crontab -e

*/1 * * * * cd /home/youruser/scripts/restarter;./restarter.sh

Cron checks the process every minute, and restart it, if it crashed.

This script is for the world process, you can easily adapt it for realmd

Link to comment
Share on other sites

  • 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