Files
Fractured/scripts/start-azeroth-servers.sh
Docker Build fbd6ea47f2 Switch server scripts to tmux for panel console access
Rewrite start-azeroth-servers.sh to launch auth/worldserver in named
tmux sessions instead of nohup/disown. Add kill-azeroth-servers.sh to
tear down sessions and stray processes. Update vps-update-server.sh
with a --restart flag that stops servers before compile and restarts
them in tmux after.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 21:39:33 -05:00

72 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Start AzerothCore authserver + worldserver in named tmux sessions.
# Kills any already-running sessions first (acts as a restart).
#
# Usage:
# bash scripts/start-azeroth-servers.sh
# AZEROTH_BIN=/path/to/bin bash scripts/start-azeroth-servers.sh
#
# Environment:
# AZEROTH_BIN — directory with authserver and worldserver (default: /home/fractured-panel/azeroth-server/bin)
# AZEROTH_LOG_DIR — log directory (default: <parent of bin>/logs)
#
# tmux sessions:
# authserver — authserver console
# worldserver — worldserver console
set -euo pipefail
BIN_DIR="${AZEROTH_BIN:-/home/fractured-panel/azeroth-server/bin}"
BASE_DIR="$(cd "$(dirname "$BIN_DIR")" && pwd)"
LOG_DIR="${AZEROTH_LOG_DIR:-${BASE_DIR}/logs}"
CONF_DIR="${BASE_DIR}/etc"
AUTH_BIN="${BIN_DIR}/authserver"
WORLD_BIN="${BIN_DIR}/worldserver"
AUTH_SESSION="authserver"
WORLD_SESSION="worldserver"
if ! command -v tmux &>/dev/null; then
echo "error: tmux is not installed" >&2
exit 1
fi
if [[ ! -x "$AUTH_BIN" ]]; then
echo "error: not found or not executable: $AUTH_BIN" >&2
exit 1
fi
if [[ ! -x "$WORLD_BIN" ]]; then
echo "error: not found or not executable: $WORLD_BIN" >&2
exit 1
fi
mkdir -p "$LOG_DIR"
# Tear down existing sessions (ignore errors if they don't exist)
tmux kill-session -t "$AUTH_SESSION" 2>/dev/null || true
tmux kill-session -t "$WORLD_SESSION" 2>/dev/null || true
# Also kill any stray processes not managed by tmux
pkill -x authserver 2>/dev/null || true
pkill -x worldserver 2>/dev/null || true
sleep 1
# Launch authserver in a tmux session
tmux new-session -d -s "$AUTH_SESSION" -c "$BIN_DIR" \
"$AUTH_BIN -c ${CONF_DIR}/authserver.conf 2>&1 | tee -a ${LOG_DIR}/authserver.log"
sleep 2
# Launch worldserver in a tmux session
tmux new-session -d -s "$WORLD_SESSION" -c "$BIN_DIR" \
"$WORLD_BIN -c ${CONF_DIR}/worldserver.conf 2>&1 | tee -a ${LOG_DIR}/worldserver.log"
echo "Started servers in tmux sessions."
echo " tmux attach -t $AUTH_SESSION — authserver console"
echo " tmux attach -t $WORLD_SESSION — worldserver console"
echo "Bin: $BIN_DIR"
echo "Config: $CONF_DIR"
echo "Logs: $LOG_DIR/authserver.log"
echo " $LOG_DIR/worldserver.log"