Jump to content

Mangos restarter with GDB


Guest LilleCarl_

Recommended Posts

Do anyone have a mangos restarter which starts mangos with gdb (and restarts it with GDB as it crashes)

And ofc save logs.

Would like to do some crashfixing ^^

Regards!

Link to comment
Share on other sites

I use this (Based on a TrinityCore Restarter script):

restarter:

#!/bin/bash
screen -A -m -d -S restarter ./restarter-bin

restarter-bin

#!/bin/bash

######################
GDB_ENABLED=1
GDB="mangos.gdb"
WORLDSERVER="core.pid" ### Put here the pid you configured on your mangosd.conf file ###
AUTHSERVER="realm.pid"   ### Put here the pid you configured on your reamld.conf file ###

### If you want to have more realms runing, just uncoment or copy this line ###
# EXTRAWORLDSERVER="world.pid" ### Put here the pid you configured on your mangosd.conf file ###


WORLD_CONFIG="../etc/mangosd.conf"
REALM_CONFIG="../etc/realmd.conf"

### If you want to have more realms runing, just uncoment or copy this line ###
# EXTRAWORLD_CONFIG="../etc/extramangosd.conf"

WORLD_SCREEN_NAME="mangos"
REALM_SCREEN_NAME="realm"

### If you want to have more realms runing, just uncoment or copy this line ###
# EXTRAWORLD_SCREEN_NAME="mangos"


TRACE_BEGIN_STRING="SIGSEGV"
TRACE_FILE="trace.log"
ERR_FILE="error.log"
SYSLOG="system.log"
SYSERR="system.err"
LINKS_FILE="crash_links.link"
######################

function checkStatus() {
       if [ -d "/proc/"$1 ]; then
               eval "TEST=1"
       else
               eval "TEST=0"
       fi
}

while :
do
       PID=$(cat $WORLDSERVER)
       checkStatus $PID
       if [ $TEST -eq 0 ]; then
               DATE=$(date)
               echo "Restarting Mangos($DATE)"
               if [ $GDB_ENABLED -eq 1 ]; then
                       grep -B 10 -A 1800 "$TRACE_BEGIN_STRING" "$SYSLOG" >> "$TRACE_FILE"
                       echo "------------------`date +"%Y-%m-%d_%H-%M-%S"`------------------" >> "$TRACE_FILE"
                       cat "$TRACE_FILE" | ./paster | grep "http" >> "$LINKS_FILE"
                       cat "$SYSERR" > "$ERR_FILE"
                       screen -A -m -d -S $WORLD_SCREEN_NAME ./start mangosd $GDB "$WORLD_CONFIG" "$SYSLOG" "$SYSERR" 1
               fi

               if [ $GDB_ENABLED -eq 0 ]; then
                       screen -A -m -d -S $WORLD_SCREEN_NAME ./start mangos null "$WORLD_CONFIG" null null 0
               fi
       fi

### If you want to have more realms runing, just uncoment or copy those lines ###
#       PID=$(cat $EXTRAWORLDSERVER)
#       checkStatus $PID
#       if [ $TEST -eq 0 ]; then
#               DATE=$(date)
#               echo "Restarting Mangos($DATE)"
#               if [ $GDB_ENABLED -eq 1 ]; then
#                       grep -B 10 -A 1800 "$TRACE_BEGIN_STRING" "$SYSLOG" > "$TRACE_FILE"
#                       cat "$TRACE_FILE" | ./paster | grep "http" >> "$LINKS_FILE"
#                       cat "$SYSERR" > "$ERR_FILE"
#                       screen -A -m -d -S $EXTRAWORLD_SCREEN_NAME ./start mangos $GDB "$EXTRAWORLD_CONFIG" "$SYSLOG" "$SYSERR" 1
#               fi
#               
#               if [ $GDB_ENABLED -eq 0 ]; then
#                       screen -A -m -d -S $EXTRAWORLD_SCREEN_NAME ./start mangos null "$EXTRAWORLD_CONFIG" null null 0
#               fi
#       fi

       PID=$(cat "$AUTHSERVER")
       checkStatus $PID
       if [ $TEST -eq 0 ]; then
               DATE=$(date)
               echo "Restarting Mangos Realm ($DATE)"
               screen -A -m -d -S $REALM_SCREEN_NAME ./start realmd null "$REALM_CONFIG"
       fi
       sleep 45
done

start

#!/bin/bash

#GDB_FILE=$2
#CONFIG=$3
#SYSLOG=$4
#SYSERR=$5
#GBD_ENABLED=$6

case $1 in
       mangosd)
               if [ $6 -eq 1 ]; then
                       echo "run -c $3" > $2
                       echo "bt" >> $2
                       echo "bt full" >> $2
                       echo "info thread" >> $2
                       echo "thread apply all backtrace full" >> $2

                       gdb ./mangosd-x $2 --batch >$4 2>$5
               fi

               if [ $6 -eq 0 ]; then
                       ./mangosd-c $3
               fi
       ;;

       realmd)
               ./realmd-c $3
       ;;
esac

Its maybe a bit outdated (binary names) but it worked nice,

(if you have suggestions or improvements pleas tell me ;)

Link to comment
Share on other sites

Wow, seems to be way more awesome then the one i found! A suggestion would be to have a folder called "crashes" and create folders after date/time where you put the crashlogs (auto) so it doesnt gay out being just one big file, and making you miss crashes (in case you have more then one crash issue)

And btw, i already solved my crash issue, but it is great that we collect this kind of tools! :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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