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:
@@ -1,40 +1,33 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Toggle debug mode: ./script.sh debug
|
# Configuration
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
ROOT_DIR="$(pwd)"
|
||||||
|
SERVER_ROOT="$ROOT_DIR/_server/azerothcore"
|
||||||
|
LOGS_PATH="/tmp/ac/logs"
|
||||||
|
CRASHES_PATH="/tmp/ac/crashes"
|
||||||
|
|
||||||
|
AUTHSERVER_SESSION="auth-session"
|
||||||
|
WORLDSERVER_SESSION="world-session"
|
||||||
|
|
||||||
|
mkdir -p "$LOGS_PATH" "$CRASHES_PATH"
|
||||||
|
|
||||||
DEBUG_MODE=0
|
DEBUG_MODE=0
|
||||||
if [[ "$1" == "debug" ]]; then
|
if [[ "$1" == "debug" ]]; then
|
||||||
DEBUG_MODE=1
|
DEBUG_MODE=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Paths for logs and crash dumps
|
# Helper function to start tmux session
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
export LOGS_PATH="/tmp/ac/logs"
|
|
||||||
export CRASHES_PATH="/tmp/ac/crashes"
|
|
||||||
|
|
||||||
# Ensure directories exist
|
|
||||||
mkdir -p "$LOGS_PATH" "$CRASHES_PATH"
|
|
||||||
|
|
||||||
##########################################################################################
|
|
||||||
# Sessions
|
|
||||||
##########################################################################################
|
|
||||||
AUTHSERVER_SESSION="authserver"
|
|
||||||
WORLDSERVER_SESSION="worldserver"
|
|
||||||
|
|
||||||
# Path to binaries
|
|
||||||
AUTH_EXE="${SERVER_ROOT}/env/dist/bin/authserver"
|
|
||||||
WORLD_EXE="${SERVER_ROOT}/env/dist/bin/worldserver"
|
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
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."
|
echo "Tmux session '$session_name' already exists, sending command..."
|
||||||
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"
|
||||||
@@ -44,39 +37,41 @@ start_tmux_session() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the command inside tmux
|
|
||||||
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 | tee -a $log_file" C-m
|
tmux send-keys -t "$session_name" "$command | tee -a $log_file" C-m
|
||||||
|
echo "Running '$command' in $session_name, logging to $log_file"
|
||||||
echo "Running '$command' inside $session_name, logging to $log_file"
|
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Start servers
|
# Start authserver (always normal)
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
start_tmux_session "$AUTHSERVER_SESSION" "$SERVER_ROOT/acore.sh run-authserver" "$LOGS_PATH/authserver.log"
|
||||||
|
|
||||||
# Authserver always normal
|
##########################################################################################
|
||||||
start_tmux_session "$AUTHSERVER_SESSION" "$AUTH_EXE" "$LOGS_PATH/authserver.log"
|
# Start worldserver
|
||||||
|
##########################################################################################
|
||||||
# Worldserver normal or debug
|
|
||||||
if [[ $DEBUG_MODE -eq 1 ]]; then
|
if [[ $DEBUG_MODE -eq 1 ]]; then
|
||||||
|
# Debug mode: run binary directly under GDB
|
||||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||||
GDB_LOG="$CRASHES_PATH/worldserver_gdb_$TIMESTAMP.log"
|
GDB_LOG="$CRASHES_PATH/worldserver_gdb_$TIMESTAMP.log"
|
||||||
WORLD_COMMAND="gdb -ex \"set logging file $GDB_LOG\" \
|
|
||||||
-ex \"set logging enabled on\" \
|
GDB_CMD="gdb -ex \"set logging file $GDB_LOG\" \
|
||||||
-ex \"run\" \
|
-ex \"set logging enabled on\" \
|
||||||
-ex \"bt full\" \
|
-ex \"run\" \
|
||||||
-ex \"quit\" \
|
-ex \"bt full\" \
|
||||||
--args $WORLD_EXE"
|
-ex \"quit\" \
|
||||||
echo "DEBUG MODE: Running worldserver under GDB"
|
--args $SERVER_ROOT/env/dist/bin/worldserver"
|
||||||
|
|
||||||
|
start_tmux_session "$WORLDSERVER_SESSION" "$GDB_CMD" "$LOGS_PATH/worldserver.log"
|
||||||
|
|
||||||
|
echo "DEBUG MODE: worldserver running under GDB, crash log: $GDB_LOG"
|
||||||
|
|
||||||
else
|
else
|
||||||
WORLD_COMMAND="$WORLD_EXE"
|
# Normal mode: use acore.sh for auto-restart
|
||||||
|
start_tmux_session "$WORLDSERVER_SESSION" "$SERVER_ROOT/acore.sh run-worldserver" "$LOGS_PATH/worldserver.log"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
start_tmux_session "$WORLDSERVER_SESSION" "$WORLD_COMMAND" "$LOGS_PATH/worldserver.log"
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Launch interactive menu if needed
|
# Optional: launch interactive menu
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
source "${ROOT_DIR}/script/menu.sh"
|
source "$ROOT_DIR/script/menu.sh"
|
||||||
|
|||||||
Reference in New Issue
Block a user