latest sources commit
This commit is contained in:
50
apps/startup-scripts/conf.sh.dist
Normal file
50
apps/startup-scripts/conf.sh.dist
Normal file
@@ -0,0 +1,50 @@
|
||||
# enable/disable GDB execution
|
||||
export GDB_ENABLED=0
|
||||
|
||||
# [optional] gdb file
|
||||
# default: gdb.conf
|
||||
export GDB=""
|
||||
|
||||
# directory where binary are stored
|
||||
export BINPATH=""
|
||||
|
||||
# Put here the pid you configured on your worldserver.conf file
|
||||
# needed when GDB_ENABLED=1
|
||||
export SERVERPID=""
|
||||
|
||||
# path to configuration file (including the file name)
|
||||
# ex: /home/user/azerothcore/etc/worldserver.conf
|
||||
export CONFIG=""
|
||||
|
||||
# path of log files
|
||||
# needed by restarter to store its logs
|
||||
export LOGS_PATH="";
|
||||
|
||||
# exec name
|
||||
# ex: worldserver
|
||||
export SERVERBIN=""
|
||||
|
||||
# prefix name for log files
|
||||
# to avoid collision with other restarters
|
||||
export LOG_PREFIX_NAME=""
|
||||
|
||||
# [optional] name of screen service
|
||||
# if no specified, screen util won't be used
|
||||
export SCREEN_NAME=""
|
||||
|
||||
# [optional] overwrite default screen options: -A -m -d -S
|
||||
# WARNING: if you are running it under a systemd service
|
||||
# please do not remove -m -d arguments from screen if are you using it,
|
||||
# or keep WITH_CONSOLE=0 .
|
||||
# otherwise the journald-logging system will take 100% of CPU slowing
|
||||
# down the whole machine. It's because a systemd service should have
|
||||
# low console output.
|
||||
export SCREEN_OPTIONS=""
|
||||
|
||||
# enable/disable it to show the output
|
||||
# within console, if disable the output will be redirect to
|
||||
# logging files
|
||||
#
|
||||
export WITH_CONSOLE=0
|
||||
|
||||
|
||||
14
apps/startup-scripts/examples/restarter-auth.sh
Normal file
14
apps/startup-scripts/examples/restarter-auth.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PATH_RUNENGINE="./"
|
||||
|
||||
source "$PATH_RUNENGINE/run-engine"
|
||||
|
||||
# you must create your conf
|
||||
# copying conf.sh.dist
|
||||
# and renaming as below
|
||||
source "./conf-auth.sh"
|
||||
|
||||
restarter
|
||||
|
||||
|
||||
14
apps/startup-scripts/examples/restarter-world.sh
Normal file
14
apps/startup-scripts/examples/restarter-world.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PATH_RUNENGINE="./"
|
||||
|
||||
source "$PATH_RUNENGINE/run-engine"
|
||||
|
||||
# you must create your conf
|
||||
# copying conf.sh.dist
|
||||
# and renaming as below
|
||||
source "./conf-world.sh"
|
||||
|
||||
restarter
|
||||
|
||||
|
||||
13
apps/startup-scripts/examples/starter-auth.sh
Normal file
13
apps/startup-scripts/examples/starter-auth.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PATH_RUNENGINE="./"
|
||||
|
||||
source "$PATH_RUNENGINE/run-engine"
|
||||
|
||||
# you must create your conf
|
||||
# copying conf.sh.dist
|
||||
# and renaming as below
|
||||
source "./conf-auth.sh"
|
||||
|
||||
starter
|
||||
|
||||
14
apps/startup-scripts/examples/starter-world.sh
Normal file
14
apps/startup-scripts/examples/starter-world.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PATH_RUNENGINE="./"
|
||||
|
||||
source "$PATH_RUNENGINE/run-engine"
|
||||
|
||||
# you must create your conf
|
||||
# copying conf.sh.dist
|
||||
# and renaming as below
|
||||
source "./conf-world.sh"
|
||||
|
||||
starter
|
||||
|
||||
|
||||
7
apps/startup-scripts/gdb.conf
Normal file
7
apps/startup-scripts/gdb.conf
Normal file
@@ -0,0 +1,7 @@
|
||||
set logging on
|
||||
set debug timestamp
|
||||
run
|
||||
bt
|
||||
bt full
|
||||
info thread
|
||||
thread apply all backtrace full
|
||||
115
apps/startup-scripts/run-engine
Normal file
115
apps/startup-scripts/run-engine
Normal file
@@ -0,0 +1,115 @@
|
||||
export RUN_ENGINE_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# load default conf
|
||||
if [ -e "$RUN_ENGINE_PATH/conf.dist" ]; then
|
||||
source "$RUN_ENGINE_PATH/conf.sh.dist"
|
||||
fi
|
||||
|
||||
function finish {
|
||||
if [ ! -z "$SCREEN_NAME" ]; then
|
||||
screen -X -S "$SCREEN_NAME" quit
|
||||
fi
|
||||
}
|
||||
|
||||
# disabled for now, but could be useful if we want
|
||||
# shutdown the process if restarter crashes for some reason
|
||||
# trap finish EXIT
|
||||
|
||||
function configureFiles() {
|
||||
TRACE_BEGIN_STRING="SIGSEGV"
|
||||
TRACE_FILE="$LOGS_PATH/"$LOG_PREFIX_NAME"_trace.log"
|
||||
ERR_FILE="$LOGS_PATH/"$LOG_PREFIX_NAME"_error.log"
|
||||
SYSLOG="$LOGS_PATH/"$LOG_PREFIX_NAME"_system.log"
|
||||
SYSERR="$LOGS_PATH/"$LOG_PREFIX_NAME"_system.err"
|
||||
LINKS_FILE="$LOGS_PATH/"$LOG_PREFIX_NAME"_crash_links.link"
|
||||
}
|
||||
|
||||
function checkStatus() {
|
||||
local ret=1
|
||||
# wipe do : destroy old screens + ls
|
||||
#screen -wipe
|
||||
#if screen -ls $1 | grep -q "No Sockets found"
|
||||
#then
|
||||
# return 0
|
||||
#fi
|
||||
|
||||
local gdbres=$(pgrep -f "gdb -x $GDB --batch $SERVERBIN")
|
||||
if [[ $GDB_ENABLED -eq 1 && ! -z $gdbres ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
#
|
||||
# This is a specific check for Azeroth Core in case of screen failure
|
||||
# It is possible since same binary file cannot be launched with same configuration file
|
||||
# This is an extra check
|
||||
#
|
||||
local binres=$(pgrep -f "$SERVERBIN -c $CONFIG")
|
||||
if [ ! -z $binres ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function run() {
|
||||
echo $1
|
||||
if [ ! -z $1 ]; then
|
||||
local OPTIONS="-A -m -d -S"
|
||||
if [ ! -z "$SCREEN_OPTIONS" ]; then
|
||||
OPTIONS=$SCREEN_OPTIONS
|
||||
fi
|
||||
|
||||
echo "> Starting with screen ( screen $OPTIONS )"
|
||||
|
||||
screen $OPTIONS $1 "$RUN_ENGINE_PATH/starter" $2 $3 "$4" "$5" "$6" $7 "$BINPATH/crashes"
|
||||
else
|
||||
$RUN_ENGINE_PATH/starter $2 $3 "$4" "$5" "$6" $7 "$BINPATH/crashes"
|
||||
fi
|
||||
}
|
||||
|
||||
function starter() {
|
||||
cd $BINPATH
|
||||
|
||||
mkdir -p "$LOGS_PATH"
|
||||
mkdir -p "$BINPATH"/crashes
|
||||
|
||||
configureFiles
|
||||
|
||||
run "$SCREEN_NAME" "$SERVERBIN" "$GDB" "$CONFIG" "$SYSLOG" "$SYSERR" "$GDB_ENABLED"
|
||||
}
|
||||
|
||||
|
||||
function restarter() {
|
||||
cd $BINPATH
|
||||
|
||||
mkdir -p "$LOGS_PATH"
|
||||
mkdir -p "$BINPATH"/crashes
|
||||
|
||||
configureFiles
|
||||
|
||||
if [ ! -f $TRACE_FILE ]; then
|
||||
touch $TRACE_FILE
|
||||
fi
|
||||
|
||||
while :
|
||||
do
|
||||
if checkStatus $SCREEN_NAME; then
|
||||
DATE=$(date)
|
||||
echo "Restarting $SCREEN_NAME Core blizz($DATE)"
|
||||
if [ $GDB_ENABLED -eq 1 ]; then
|
||||
echo "GDB enabled"
|
||||
grep -B 10 -A 1800 "$TRACE_BEGIN_STRING" "$SYSLOG" >> "$TRACE_FILE"
|
||||
cat "$SYSERR" > "$ERR_FILE"
|
||||
run "$SCREEN_NAME" "$SERVERBIN" "$GDB" "$CONFIG" "$SYSLOG" "$SYSERR" 1
|
||||
fi
|
||||
|
||||
if [ $GDB_ENABLED -eq 0 ]; then
|
||||
echo "GDB disabled"
|
||||
run "$SCREEN_NAME" "$SERVERBIN" null "$CONFIG" null null 0
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
done
|
||||
}
|
||||
|
||||
70
apps/startup-scripts/simple-restarter
Normal file
70
apps/startup-scripts/simple-restarter
Normal file
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#PARAMETER 1: directory
|
||||
#PARAMETER 2: binary file
|
||||
#PARAMETER 3: gdb on/off
|
||||
|
||||
bin_path="${1:-$AC_RESTARTER_BINPATH}"
|
||||
bin_file="${2:-$AC_RESTARTER_BINFILE}"
|
||||
with_gdb="${3:-$AC_RESTARTER_WITHGDB}"
|
||||
|
||||
CURRENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd )
|
||||
|
||||
_instant_crash_count=0
|
||||
_restart_count=0
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 path filename"
|
||||
echo "Example: $0 $HOME/azerothcore/bin worldserver"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while true
|
||||
do
|
||||
if [ ! -f "$bin_path/$bin_file" ]; then
|
||||
echo "$bin_path/$bin_file doesn't exists!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
STARTING_TIME=$(date +%s)
|
||||
|
||||
cd "$bin_path";
|
||||
|
||||
if [ "$with_gdb" = true ]; then
|
||||
echo "Running with GDB enabled"
|
||||
gdb -x "$CURRENT_PATH/gdb.conf" --batch "./$bin_file"
|
||||
else
|
||||
echo "Running without GDB"
|
||||
"./$bin_file"
|
||||
fi
|
||||
|
||||
_exit_code=$?
|
||||
|
||||
echo "exit code: $_exit_code"
|
||||
# stop restarter on SIGKILL (disabled for now)
|
||||
# 128 + 9 (SIGKILL)
|
||||
#if [ $_exit_code -eq 137 ]; then
|
||||
# echo "$bin_file has been killed"
|
||||
# exit 0
|
||||
#fi
|
||||
|
||||
echo "$bin_file terminated, restarting..."
|
||||
|
||||
ENDING_TIME=$(date +%s)
|
||||
DIFFERENCE=$(( $ENDING_TIME - $STARTING_TIME ))
|
||||
|
||||
((_restart_count++))
|
||||
echo "$bin_file Terminated after $DIFFERENCE seconds, termination count: : $_restart_count"
|
||||
|
||||
if [ $DIFFERENCE -lt 10 ]; then
|
||||
# increment instant crash if runtime is lower than 10 seconds
|
||||
((_instant_crash_count++))
|
||||
else
|
||||
_instant_crash_count=0 # reset count
|
||||
fi
|
||||
|
||||
if [ $_instant_crash_count -gt 5 ]; then
|
||||
echo "$bin_file Restarter exited. Infinite crash loop prevented. Please check your system"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
32
apps/startup-scripts/starter
Normal file
32
apps/startup-scripts/starter
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
GDB_FILE="$2"
|
||||
CONFIG="$3"
|
||||
SYSLOG="$4"
|
||||
SYSERR="$5"
|
||||
GDB_ENABLED="$6"
|
||||
CRASHES_PATH="$7"
|
||||
|
||||
if [ $GDB_ENABLED -eq 1 ]; then
|
||||
echo "set logging file "$CRASHES_PATH"/gdb-$(date +%Y-%m-%d-%H-%M-%S).txt" > "$GDB_FILE"
|
||||
echo "set logging on" >> "$GDB_FILE"
|
||||
echo "set debug timestamp" >> "$GDB_FILE"
|
||||
echo "run -c $3" >> "$GDB_FILE"
|
||||
echo "bt" >> "$GDB_FILE"
|
||||
echo "bt full" >> "$GDB_FILE"
|
||||
echo "info thread" >> "$GDB_FILE"
|
||||
echo "thread apply all backtrace full" >> "$GDB_FILE"
|
||||
|
||||
[ ! -f "$SYSLOG" ] && touch "$SYSLOG"
|
||||
[ ! -f "$SYSERR" ] && touch "$SYSERR"
|
||||
|
||||
if [ $WITH_CONSOLE -eq 0 ]; then
|
||||
gdb -x $GDB_FILE --batch $1 >> "$SYSLOG" 2>> "$SYSERR"
|
||||
else
|
||||
echo "> Console enabled"
|
||||
gdb -x $GDB_FILE --batch $1 > >(tee ${SYSLOG}) 2> >(tee ${SYSERR} >&2)
|
||||
fi
|
||||
|
||||
elif [ $GDB_ENABLED -eq 0 ]; then
|
||||
"./$1" -c "$CONFIG"
|
||||
fi
|
||||
Reference in New Issue
Block a user