mirror of
https://github.com/hermensbas/azerothcore_installer.git
synced 2026-01-13 00:28:33 +00:00
Update 6_server-start.sh
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
##########################################################################################
|
##########################################################################################
|
||||||
export LOGS_PATH="/tmp/ac/logs"
|
export LOGS_PATH="/tmp/ac/logs"
|
||||||
export CRASHES_PATH="/tmp/ac/crashes"
|
export CRASHES_PATH="/tmp/ac/crashes"
|
||||||
|
|
||||||
mkdir -p "$LOGS_PATH" "$CRASHES_PATH"
|
mkdir -p "$LOGS_PATH" "$CRASHES_PATH"
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
@@ -13,17 +14,30 @@ mkdir -p "$LOGS_PATH" "$CRASHES_PATH"
|
|||||||
AUTHSERVER_SESSION="auth-session"
|
AUTHSERVER_SESSION="auth-session"
|
||||||
WORLDSERVER_SESSION="world-session"
|
WORLDSERVER_SESSION="world-session"
|
||||||
|
|
||||||
|
# Timestamps for log files
|
||||||
|
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
|
||||||
|
AUTH_LOG="$LOGS_PATH/authserver_$TIMESTAMP.log"
|
||||||
|
WORLD_LOG="$LOGS_PATH/worldserver_$TIMESTAMP.log"
|
||||||
|
WORLD_CRASH_LOG="$CRASHES_PATH/worldserver_gdb_$TIMESTAMP.log"
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Helper to start a tmux session and run a command
|
# Check debug toggle
|
||||||
|
##########################################################################################
|
||||||
|
DEBUG_MODE=0
|
||||||
|
if [[ "$1" == "debug" ]]; then
|
||||||
|
DEBUG_MODE=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Helper to start a tmux session
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
start_tmux_session() {
|
start_tmux_session() {
|
||||||
local session_name=$1
|
local session_name=$1
|
||||||
local command=$2
|
local command=$2
|
||||||
local log_file=$3
|
local log_file=$3
|
||||||
|
|
||||||
# Create session if it doesn't exist
|
|
||||||
if tmux has-session -t "$session_name" 2>/dev/null; then
|
if tmux has-session -t "$session_name" 2>/dev/null; then
|
||||||
echo "Tmux session '$session_name' already exists, attaching command..."
|
echo "Tmux session '$session_name' already exists."
|
||||||
else
|
else
|
||||||
if tmux new-session -d -s "$session_name"; then
|
if tmux new-session -d -s "$session_name"; then
|
||||||
echo "Created tmux session: $session_name"
|
echo "Created tmux session: $session_name"
|
||||||
@@ -33,37 +47,42 @@ start_tmux_session() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the command in tmux and pipe to tee
|
tmux send-keys -t "$session_name" "export LOGS_PATH=$LOGS_PATH; export CRASHES_PATH=$CRASHES_PATH" C-m
|
||||||
tmux send-keys -t "$session_name" "$command 2>&1 | tee $log_file" C-m
|
tmux send-keys -t "$session_name" "$command | tee $log_file" C-m
|
||||||
|
|
||||||
echo "Running '$command' in $session_name, logging to $log_file"
|
echo "Running '$command' in $session_name, logging to $log_file"
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Determine mode (debug or normal)
|
# Prepare commands
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
MODE="$1" # script.sh debug
|
SERVER_ROOT="$(pwd)"
|
||||||
DEBUG_MODE=0
|
|
||||||
if [[ "$MODE" == "debug" ]]; then
|
|
||||||
DEBUG_MODE=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
##########################################################################################
|
# Authserver always via acore.sh for auto-restart
|
||||||
# Prepare timestamped logs
|
|
||||||
##########################################################################################
|
|
||||||
AUTH_LOG="$LOGS_PATH/authserver_$(date +%Y%m%d_%H%M%S).log"
|
|
||||||
WORLD_LOG="$LOGS_PATH/worldserver_$(date +%Y%m%d_%H%M%S).log"
|
|
||||||
WORLD_CRASH_LOG="$CRASHES_PATH/worldserver_gdb_$(date +%Y%m%d_%H%M%S).log"
|
|
||||||
|
|
||||||
##########################################################################################
|
|
||||||
# Start authserver
|
|
||||||
##########################################################################################
|
|
||||||
AUTH_CMD="${SERVER_ROOT}/acore.sh run-authserver"
|
AUTH_CMD="${SERVER_ROOT}/acore.sh run-authserver"
|
||||||
start_tmux_session "$AUTHSERVER_SESSION" "$AUTH_CMD" "$AUTH_LOG"
|
|
||||||
|
|
||||||
##########################################################################################
|
|
||||||
# Start worldserver
|
|
||||||
##########################################################################################
|
|
||||||
if [[ $DEBUG_MODE -eq 1 ]]; then
|
if [[ $DEBUG_MODE -eq 1 ]]; then
|
||||||
echo "DEBUG MODE: Running worldserver under GDB"
|
echo "DEBUG MODE: Running worldserver under GDB"
|
||||||
WORLD_CMD="gdb -ex 'set logging file $WORLD_CRASH_LOG' \
|
WORLD_CMD="gdb -ex 'set logging file $WORLD_CRASH_LOG' \
|
||||||
|
-ex 'set logging enabled on' \
|
||||||
|
-ex 'run' \
|
||||||
|
-ex 'bt full' \
|
||||||
|
-ex 'quit' \
|
||||||
|
--args ${SERVER_ROOT}/env/dist/bin/worldserver"
|
||||||
|
else
|
||||||
|
WORLD_CMD="${SERVER_ROOT}/acore.sh run-worldserver"
|
||||||
|
fi
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Start servers
|
||||||
|
##########################################################################################
|
||||||
|
start_tmux_session "$AUTHSERVER_SESSION" "$AUTH_CMD" "$AUTH_LOG"
|
||||||
|
start_tmux_session "$WORLDSERVER_SESSION" "$WORLD_CMD" "$WORLD_LOG"
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Optional: show menu if exists
|
||||||
|
##########################################################################################
|
||||||
|
if [[ -f "${ROOT_DIR}/script/menu.sh" ]]; then
|
||||||
|
source "${ROOT_DIR}/script/menu.sh"
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user