Update 6_server-start.sh

This commit is contained in:
bashermens
2026-01-10 20:42:26 +01:00
committed by GitHub
parent 2ca4a186f3
commit 8089819dd4

View File

@@ -9,7 +9,7 @@ export CRASHES_PATH="/tmp/ac/crashes"
mkdir -p "$LOGS_PATH" "$CRASHES_PATH"
##########################################################################################
# Tmux sessions
# Sessions
##########################################################################################
AUTHSERVER_SESSION="auth-session"
WORLDSERVER_SESSION="world-session"
@@ -21,13 +21,12 @@ WORLD_LOG="$LOGS_PATH/worldserver_$TIMESTAMP.log"
WORLD_CRASH_LOG="$CRASHES_PATH/worldserver_gdb_$TIMESTAMP.log"
##########################################################################################
# Determine ROOT_DIR based on script location
# Determine SERVER_ROOT based on script location (works with aliases)
##########################################################################################
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SERVER_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# Paths to binaries
AUTH_BIN="$ROOT_DIR/_server/azerothcore/env/dist/bin/authserver"
WORLD_BIN="$ROOT_DIR/_server/azerothcore/env/dist/bin/worldserver"
RUN_ENGINE="$SERVER_ROOT/_server/azerothcore/env/dist/run-engine"
chmod +x "$RUN_ENGINE"
##########################################################################################
# Check debug toggle
@@ -45,22 +44,25 @@ start_tmux_session() {
local command=$2
local log_file=$3
# Create session if it doesn't exist
# If session exists, attach and return
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. Attaching..."
tmux attach-session -t "$session_name"
return 0
fi
# Create new session
if tmux new-session -d -s "$session_name"; then
echo "Created tmux session: $session_name"
else
if tmux new-session -d -s "$session_name"; then
echo "Created tmux session: $session_name"
else
echo "Error creating tmux session: $session_name"
return 1
fi
echo "Error creating tmux session: $session_name"
return 1
fi
# Export environment variables inside tmux
tmux send-keys -t "$session_name" "export LOGS_PATH=$LOGS_PATH; export CRASHES_PATH=$CRASHES_PATH" C-m
# Run the command and pipe output to a new log file
# Run the command and pipe output to a log file
tmux send-keys -t "$session_name" "$command | tee $log_file" C-m
echo "Running '$command' in $session_name, logging to $log_file"
@@ -71,20 +73,23 @@ start_tmux_session() {
# Prepare commands
##########################################################################################
# Authserver binary (normal mode)
AUTH_CMD="$AUTH_BIN"
# Authserver always via acore.sh for auto-restart
AUTH_CMD="${SERVER_ROOT}/acore.sh run-authserver"
# Worldserver binary
# Worldserver command
WORLD_CMD="$RUN_ENGINE restart worldserver \
--bin-path ${SERVER_ROOT}/_server/azerothcore/env/dist/bin \
--server-config ${SERVER_ROOT}/conf/worldserver.conf \
--session-manager tmux \
--logs-path $LOGS_PATH \
--crashes-path $CRASHES_PATH"
# Add GDB if debug mode
if [[ $DEBUG_MODE -eq 1 ]]; then
echo "DEBUG MODE: Running worldserver under GDB"
WORLD_CMD="gdb -ex 'set logging file $WORLD_CRASH_LOG' \
-ex 'set logging enabled on' \
-ex 'run' \
-ex 'bt full' \
-ex 'quit' \
--args $WORLD_BIN"
else
WORLD_CMD="$WORLD_BIN"
WORLD_CMD="$WORLD_CMD --gdb-enabled 1"
# Optional: log GDB crashes separately
WORLD_CMD="$WORLD_CMD --gdb-log $WORLD_CRASH_LOG"
fi
##########################################################################################
@@ -96,6 +101,6 @@ 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"
if [[ -f "${SERVER_ROOT}/script/menu.sh" ]]; then
source "${SERVER_ROOT}/script/menu.sh"
fi