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>
This commit is contained in:
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
# Kill AzerothCore authserver + worldserver tmux sessions and any stray processes.
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/kill-azeroth-servers.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
AUTH_SESSION="authserver"
|
||||
WORLD_SESSION="worldserver"
|
||||
|
||||
echo "Stopping servers..."
|
||||
|
||||
# Kill tmux sessions
|
||||
if tmux has-session -t "$WORLD_SESSION" 2>/dev/null; then
|
||||
tmux kill-session -t "$WORLD_SESSION"
|
||||
echo " killed tmux session: $WORLD_SESSION"
|
||||
else
|
||||
echo " no tmux session: $WORLD_SESSION"
|
||||
fi
|
||||
|
||||
if tmux has-session -t "$AUTH_SESSION" 2>/dev/null; then
|
||||
tmux kill-session -t "$AUTH_SESSION"
|
||||
echo " killed tmux session: $AUTH_SESSION"
|
||||
else
|
||||
echo " no tmux session: $AUTH_SESSION"
|
||||
fi
|
||||
|
||||
# Clean up any stray processes not managed by tmux
|
||||
if pkill -x worldserver 2>/dev/null; then
|
||||
echo " killed stray worldserver process"
|
||||
fi
|
||||
if pkill -x authserver 2>/dev/null; then
|
||||
echo " killed stray authserver process"
|
||||
fi
|
||||
|
||||
echo "Done."
|
||||
@@ -1,14 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Start AzerothCore authserver + worldserver detached from the SSH session (nohup + disown).
|
||||
# Stops any already-running authserver/worldserver processes first.
|
||||
# Start AzerothCore authserver + worldserver in named tmux sessions.
|
||||
# Kills any already-running sessions first (acts as a restart).
|
||||
#
|
||||
# Usage:
|
||||
# sudo bash scripts/start-azeroth-servers.sh
|
||||
# AZEROTH_BIN=/path/to/azeroth-server/bin bash scripts/start-azeroth-servers.sh
|
||||
# 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
|
||||
|
||||
@@ -20,6 +24,14 @@ 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
|
||||
@@ -29,23 +41,30 @@ if [[ ! -x "$WORLD_BIN" ]]; then
|
||||
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
|
||||
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
cd "$BIN_DIR"
|
||||
|
||||
nohup "$AUTH_BIN" -c "${CONF_DIR}/authserver.conf" >>"$LOG_DIR/authserver.log" 2>&1 &
|
||||
disown || true
|
||||
# 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
|
||||
|
||||
nohup "$WORLD_BIN" -c "${CONF_DIR}/worldserver.conf" >>"$LOG_DIR/worldserver.log" 2>&1 &
|
||||
disown || true
|
||||
# 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 authserver and worldserver (survives SSH disconnect)."
|
||||
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"
|
||||
|
||||
@@ -6,24 +6,25 @@
|
||||
# (see docs/DEPLOY_LINUX_VPS.md).
|
||||
#
|
||||
# What this does:
|
||||
# 1. git pull on the current branch (optional; can skip)
|
||||
# 2. ./acore.sh compiler build — or compiler all for a full clean rebuild
|
||||
# 1. Optionally kill running servers (tmux sessions)
|
||||
# 2. git pull on the current branch (optional; can skip)
|
||||
# 3. ./acore.sh compiler build — or compiler all for a full clean rebuild
|
||||
# 4. Optionally restart servers in tmux sessions
|
||||
#
|
||||
# Database migrations from data/sql/updates/ run when you next start worldserver/authserver
|
||||
# (Updates.* / SourceDirectory in *.conf). This script does not start or stop daemons unless
|
||||
# you pass --run-after or set FRACTURED_POST_UPDATE_CMD.
|
||||
# (Updates.* / SourceDirectory in *.conf).
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/vps-update-server.sh
|
||||
# bash scripts/vps-update-server.sh --full
|
||||
# bash scripts/vps-update-server.sh --no-pull
|
||||
# bash scripts/vps-update-server.sh # pull + compile only
|
||||
# bash scripts/vps-update-server.sh --restart # pull + compile + restart servers in tmux
|
||||
# bash scripts/vps-update-server.sh --full --restart # clean rebuild + restart
|
||||
# bash scripts/vps-update-server.sh --no-pull --restart # compile current tree + restart
|
||||
# bash scripts/vps-update-server.sh --dry-run
|
||||
# FRACTURED_POST_UPDATE_CMD='sudo systemctl restart fractured-world' bash scripts/vps-update-server.sh --run-after
|
||||
# bash scripts/vps-update-server.sh --run-after 'sudo systemctl restart fractured-world'
|
||||
# bash scripts/vps-update-server.sh --run-after 'custom command here'
|
||||
#
|
||||
# Environment:
|
||||
# FRACTURED_GIT_REMOTE — remote name (default: origin)
|
||||
# FRACTURED_POST_UPDATE_CMD — shell command run after a successful compile (if --run-after is passed without an argument, this is used)
|
||||
# FRACTURED_POST_UPDATE_CMD — shell command run after compile (used by bare --run-after)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
@@ -35,6 +36,7 @@ FULL_BUILD=0
|
||||
COMPILE_ONLY=0
|
||||
DRY_RUN=0
|
||||
DO_RUN_AFTER=0
|
||||
DO_RESTART=0
|
||||
INSTALL_PREFIX=""
|
||||
POST_UPDATE_CMD="${FRACTURED_POST_UPDATE_CMD:-}"
|
||||
GIT_REMOTE="${FRACTURED_GIT_REMOTE:-origin}"
|
||||
@@ -52,8 +54,9 @@ Options:
|
||||
--compile-only ./acore.sh compiler compile (incremental).
|
||||
--prefix PATH Override CMAKE_INSTALL_PREFIX (updates conf/config.sh BINPATH).
|
||||
--dry-run Print commands without running them.
|
||||
--run-after [CMD] Run shell command after successful compile. If CMD is omitted,
|
||||
uses FRACTURED_POST_UPDATE_CMD from the environment.
|
||||
--restart Kill servers before compile, restart in tmux after.
|
||||
--run-after [CMD] Run a custom shell command after successful compile.
|
||||
If CMD is omitted, uses FRACTURED_POST_UPDATE_CMD.
|
||||
|
||||
Environment:
|
||||
FRACTURED_GIT_REMOTE Git remote (default: origin).
|
||||
@@ -102,6 +105,10 @@ while [[ $# -gt 0 ]]; do
|
||||
DRY_RUN=1
|
||||
shift
|
||||
;;
|
||||
--restart)
|
||||
DO_RESTART=1
|
||||
shift
|
||||
;;
|
||||
--run-after)
|
||||
DO_RUN_AFTER=1
|
||||
shift
|
||||
@@ -140,6 +147,18 @@ fi
|
||||
|
||||
cd "$ROOT"
|
||||
|
||||
KILL_SCRIPT="${SCRIPT_DIR}/kill-azeroth-servers.sh"
|
||||
START_SCRIPT="${SCRIPT_DIR}/start-azeroth-servers.sh"
|
||||
|
||||
if [[ "$DO_RESTART" -eq 1 ]]; then
|
||||
if [[ ! -f "$KILL_SCRIPT" || ! -f "$START_SCRIPT" ]]; then
|
||||
echo "error: --restart requires kill-azeroth-servers.sh and start-azeroth-servers.sh in scripts/" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "==> stopping servers before compile"
|
||||
run bash "$KILL_SCRIPT"
|
||||
fi
|
||||
|
||||
if [[ -n "$INSTALL_PREFIX" ]]; then
|
||||
echo "==> updating conf/config.sh BINPATH to: $INSTALL_PREFIX"
|
||||
if grep -q '^BINPATH=' conf/config.sh; then
|
||||
@@ -189,6 +208,11 @@ else
|
||||
run ./acore.sh compiler build
|
||||
fi
|
||||
|
||||
if [[ "$DO_RESTART" -eq 1 ]]; then
|
||||
echo "==> restarting servers in tmux sessions"
|
||||
run bash "$START_SCRIPT"
|
||||
fi
|
||||
|
||||
if [[ "$DO_RUN_AFTER" -eq 1 ]]; then
|
||||
echo "==> post-update: $POST_UPDATE_CMD"
|
||||
if [[ "$DRY_RUN" -eq 1 ]]; then
|
||||
@@ -199,4 +223,8 @@ if [[ "$DO_RUN_AFTER" -eq 1 ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Done. Restart authserver/worldserver (or your service manager) when ready so new binaries and SQL updates apply."
|
||||
if [[ "$DO_RESTART" -eq 0 && "$DO_RUN_AFTER" -eq 0 ]]; then
|
||||
echo "Done. Run 'bash scripts/start-azeroth-servers.sh' to (re)start servers in tmux."
|
||||
else
|
||||
echo "Done."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user