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,37 +1,48 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
##########################################################################################
|
||||||
|
# AzerothCore Server Start Script
|
||||||
|
# - Normal mode: runs via acore.sh (auto-restart, normal logs)
|
||||||
|
# - Debug mode: runs worldserver under GDB (no auto-restart, crash logs)
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
##########################################################################################
|
# ===============================
|
||||||
# Configuration
|
# Configuration
|
||||||
##########################################################################################
|
# ===============================
|
||||||
ROOT_DIR="$(pwd)"
|
ROOT_DIR="/home/dev/azerothcore_installer"
|
||||||
SERVER_ROOT="$ROOT_DIR/_server/azerothcore"
|
SERVER_ROOT="$ROOT_DIR/_server/azerothcore"
|
||||||
LOGS_PATH="/tmp/ac/logs"
|
|
||||||
CRASHES_PATH="/tmp/ac/crashes"
|
|
||||||
|
|
||||||
AUTHSERVER_SESSION="auth-session"
|
AUTHSERVER_SESSION="auth-session"
|
||||||
WORLDSERVER_SESSION="world-session"
|
WORLDSERVER_SESSION="world-session"
|
||||||
|
|
||||||
|
LOGS_PATH="/tmp/ac/logs"
|
||||||
|
CRASHES_PATH="/tmp/ac/crashes"
|
||||||
|
|
||||||
mkdir -p "$LOGS_PATH" "$CRASHES_PATH"
|
mkdir -p "$LOGS_PATH" "$CRASHES_PATH"
|
||||||
|
|
||||||
|
# Timestamp for log files
|
||||||
|
NOW=$(date +"%Y%m%d_%H%M%S")
|
||||||
|
AUTH_LOG="$LOGS_PATH/authserver_$NOW.log"
|
||||||
|
WORLD_LOG="$LOGS_PATH/worldserver_$NOW.log"
|
||||||
|
GDB_LOG="$CRASHES_PATH/worldserver_gdb_$NOW.log"
|
||||||
|
|
||||||
|
# Check for debug mode
|
||||||
DEBUG_MODE=0
|
DEBUG_MODE=0
|
||||||
if [[ "$1" == "debug" ]]; then
|
if [[ "$1" == "debug" ]]; then
|
||||||
DEBUG_MODE=1
|
DEBUG_MODE=1
|
||||||
|
echo "DEBUG MODE: worldserver will run under GDB"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
# ===============================
|
||||||
AUTH_LOG="$LOGS_PATH/authserver_$TIMESTAMP.log"
|
# Helper: start tmux session
|
||||||
WORLD_LOG="$LOGS_PATH/worldserver_$TIMESTAMP.log"
|
# ===============================
|
||||||
|
|
||||||
##########################################################################################
|
|
||||||
# Helper function to start 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, sending command..."
|
echo "Tmux session '$session_name' already exists, attaching 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"
|
||||||
@@ -41,41 +52,43 @@ start_tmux_session() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Redirect output to log file (new file)
|
# Run the command in tmux, output redirected to log file (overwrite)
|
||||||
tmux send-keys -t "$session_name" "$command | tee $log_file" C-m
|
tmux send-keys -t "$session_name" "$command >$log_file 2>&1" 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 authserver (always normal)
|
# Start Authserver
|
||||||
##########################################################################################
|
# ===============================
|
||||||
start_tmux_session "$AUTHSERVER_SESSION" "$SERVER_ROOT/acore.sh run-authserver" "$AUTH_LOG"
|
AUTH_CMD="$SERVER_ROOT/acore.sh run-authserver"
|
||||||
|
start_tmux_session "$AUTHSERVER_SESSION" "$AUTH_CMD" "$AUTH_LOG"
|
||||||
|
|
||||||
##########################################################################################
|
# ===============================
|
||||||
# Start worldserver
|
# Start Worldserver
|
||||||
##########################################################################################
|
# ===============================
|
||||||
if [[ $DEBUG_MODE -eq 1 ]]; then
|
if [[ $DEBUG_MODE -eq 1 ]]; then
|
||||||
# Debug mode: run binary directly under GDB
|
WORLD_CMD="gdb -ex 'set logging file $GDB_LOG' \
|
||||||
GDB_LOG="$CRASHES_PATH/worldserver_gdb_$TIMESTAMP.log"
|
-ex 'set logging enabled on' \
|
||||||
|
-ex 'run' \
|
||||||
GDB_CMD="gdb -ex \"set logging file $GDB_LOG\" \
|
-ex 'bt full' \
|
||||||
-ex \"set logging enabled on\" \
|
-ex 'quit' \
|
||||||
-ex \"run\" \
|
|
||||||
-ex \"bt full\" \
|
|
||||||
-ex \"quit\" \
|
|
||||||
--args $SERVER_ROOT/env/dist/bin/worldserver"
|
--args $SERVER_ROOT/env/dist/bin/worldserver"
|
||||||
|
|
||||||
start_tmux_session "$WORLDSERVER_SESSION" "$GDB_CMD" "$WORLD_LOG"
|
|
||||||
|
|
||||||
echo "DEBUG MODE: worldserver running under GDB, crash log: $GDB_LOG"
|
|
||||||
|
|
||||||
else
|
else
|
||||||
# Normal mode: use acore.sh for auto-restart
|
WORLD_CMD="$SERVER_ROOT/acore.sh run-worldserver"
|
||||||
start_tmux_session "$WORLDSERVER_SESSION" "$SERVER_ROOT/acore.sh run-worldserver" "$WORLD_LOG"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################################################################################
|
start_tmux_session "$WORLDSERVER_SESSION" "$WORLD_CMD" "$WORLD_LOG"
|
||||||
# Optional: launch interactive menu
|
|
||||||
##########################################################################################
|
# ===============================
|
||||||
source "$ROOT_DIR/script/menu.sh"
|
# Launch menu
|
||||||
|
# ===============================
|
||||||
|
if [[ -f "$ROOT_DIR/script/menu.sh" ]]; then
|
||||||
|
source "$ROOT_DIR/script/menu.sh"
|
||||||
|
else
|
||||||
|
echo "WARNING: menu.sh not found at $ROOT_DIR/script/menu.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Server start script finished."
|
||||||
|
[[ $DEBUG_MODE -eq 1 ]] && echo "DEBUG: worldserver GDB log: $GDB_LOG"
|
||||||
|
|||||||
Reference in New Issue
Block a user