diff --git a/script/6_server-start.sh b/script/6_server-start.sh index 07a4658..006ed45 100755 --- a/script/6_server-start.sh +++ b/script/6_server-start.sh @@ -1,40 +1,33 @@ #!/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 if [[ "$1" == "debug" ]]; then DEBUG_MODE=1 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() { local session_name=$1 local command=$2 local log_file=$3 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 if tmux new-session -d -s "$session_name"; then echo "Created tmux session: $session_name" @@ -44,39 +37,41 @@ start_tmux_session() { 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 - - echo "Running '$command' inside $session_name, logging to $log_file" + echo "Running '$command' in $session_name, logging to $log_file" 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" - -# Worldserver normal or debug +########################################################################################## +# Start worldserver +########################################################################################## if [[ $DEBUG_MODE -eq 1 ]]; then + # Debug mode: run binary directly under GDB TIMESTAMP=$(date +%Y%m%d_%H%M%S) GDB_LOG="$CRASHES_PATH/worldserver_gdb_$TIMESTAMP.log" - WORLD_COMMAND="gdb -ex \"set logging file $GDB_LOG\" \ - -ex \"set logging enabled on\" \ - -ex \"run\" \ - -ex \"bt full\" \ - -ex \"quit\" \ - --args $WORLD_EXE" - echo "DEBUG MODE: Running worldserver under GDB" + + GDB_CMD="gdb -ex \"set logging file $GDB_LOG\" \ + -ex \"set logging enabled on\" \ + -ex \"run\" \ + -ex \"bt full\" \ + -ex \"quit\" \ + --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 - 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 -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"