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
|
#!/usr/bin/env bash
|
||||||
# Start AzerothCore authserver + worldserver detached from the SSH session (nohup + disown).
|
# Start AzerothCore authserver + worldserver in named tmux sessions.
|
||||||
# Stops any already-running authserver/worldserver processes first.
|
# Kills any already-running sessions first (acts as a restart).
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# sudo bash scripts/start-azeroth-servers.sh
|
# bash scripts/start-azeroth-servers.sh
|
||||||
# AZEROTH_BIN=/path/to/azeroth-server/bin bash scripts/start-azeroth-servers.sh
|
# AZEROTH_BIN=/path/to/bin bash scripts/start-azeroth-servers.sh
|
||||||
#
|
#
|
||||||
# Environment:
|
# Environment:
|
||||||
# AZEROTH_BIN — directory with authserver and worldserver (default: /home/fractured-panel/azeroth-server/bin)
|
# AZEROTH_BIN — directory with authserver and worldserver (default: /home/fractured-panel/azeroth-server/bin)
|
||||||
# AZEROTH_LOG_DIR — log directory (default: <parent of bin>/logs)
|
# AZEROTH_LOG_DIR — log directory (default: <parent of bin>/logs)
|
||||||
|
#
|
||||||
|
# tmux sessions:
|
||||||
|
# authserver — authserver console
|
||||||
|
# worldserver — worldserver console
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
@@ -20,6 +24,14 @@ CONF_DIR="${BASE_DIR}/etc"
|
|||||||
AUTH_BIN="${BIN_DIR}/authserver"
|
AUTH_BIN="${BIN_DIR}/authserver"
|
||||||
WORLD_BIN="${BIN_DIR}/worldserver"
|
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
|
if [[ ! -x "$AUTH_BIN" ]]; then
|
||||||
echo "error: not found or not executable: $AUTH_BIN" >&2
|
echo "error: not found or not executable: $AUTH_BIN" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -29,23 +41,30 @@ if [[ ! -x "$WORLD_BIN" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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 authserver 2>/dev/null || true
|
||||||
pkill -x worldserver 2>/dev/null || true
|
pkill -x worldserver 2>/dev/null || true
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
mkdir -p "$LOG_DIR"
|
# Launch authserver in a tmux session
|
||||||
|
tmux new-session -d -s "$AUTH_SESSION" -c "$BIN_DIR" \
|
||||||
cd "$BIN_DIR"
|
"$AUTH_BIN -c ${CONF_DIR}/authserver.conf 2>&1 | tee -a ${LOG_DIR}/authserver.log"
|
||||||
|
|
||||||
nohup "$AUTH_BIN" -c "${CONF_DIR}/authserver.conf" >>"$LOG_DIR/authserver.log" 2>&1 &
|
|
||||||
disown || true
|
|
||||||
|
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
nohup "$WORLD_BIN" -c "${CONF_DIR}/worldserver.conf" >>"$LOG_DIR/worldserver.log" 2>&1 &
|
# Launch worldserver in a tmux session
|
||||||
disown || true
|
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 "Bin: $BIN_DIR"
|
||||||
echo "Config: $CONF_DIR"
|
echo "Config: $CONF_DIR"
|
||||||
echo "Logs: $LOG_DIR/authserver.log"
|
echo "Logs: $LOG_DIR/authserver.log"
|
||||||
|
|||||||
@@ -6,24 +6,25 @@
|
|||||||
# (see docs/DEPLOY_LINUX_VPS.md).
|
# (see docs/DEPLOY_LINUX_VPS.md).
|
||||||
#
|
#
|
||||||
# What this does:
|
# What this does:
|
||||||
# 1. git pull on the current branch (optional; can skip)
|
# 1. Optionally kill running servers (tmux sessions)
|
||||||
# 2. ./acore.sh compiler build — or compiler all for a full clean rebuild
|
# 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
|
# 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
|
# (Updates.* / SourceDirectory in *.conf).
|
||||||
# you pass --run-after or set FRACTURED_POST_UPDATE_CMD.
|
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# bash scripts/vps-update-server.sh
|
# bash scripts/vps-update-server.sh # pull + compile only
|
||||||
# bash scripts/vps-update-server.sh --full
|
# bash scripts/vps-update-server.sh --restart # pull + compile + restart servers in tmux
|
||||||
# bash scripts/vps-update-server.sh --no-pull
|
# 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
|
# 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 'custom command here'
|
||||||
# bash scripts/vps-update-server.sh --run-after 'sudo systemctl restart fractured-world'
|
|
||||||
#
|
#
|
||||||
# Environment:
|
# Environment:
|
||||||
# FRACTURED_GIT_REMOTE — remote name (default: origin)
|
# 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
|
set -euo pipefail
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ FULL_BUILD=0
|
|||||||
COMPILE_ONLY=0
|
COMPILE_ONLY=0
|
||||||
DRY_RUN=0
|
DRY_RUN=0
|
||||||
DO_RUN_AFTER=0
|
DO_RUN_AFTER=0
|
||||||
|
DO_RESTART=0
|
||||||
INSTALL_PREFIX=""
|
INSTALL_PREFIX=""
|
||||||
POST_UPDATE_CMD="${FRACTURED_POST_UPDATE_CMD:-}"
|
POST_UPDATE_CMD="${FRACTURED_POST_UPDATE_CMD:-}"
|
||||||
GIT_REMOTE="${FRACTURED_GIT_REMOTE:-origin}"
|
GIT_REMOTE="${FRACTURED_GIT_REMOTE:-origin}"
|
||||||
@@ -52,8 +54,9 @@ Options:
|
|||||||
--compile-only ./acore.sh compiler compile (incremental).
|
--compile-only ./acore.sh compiler compile (incremental).
|
||||||
--prefix PATH Override CMAKE_INSTALL_PREFIX (updates conf/config.sh BINPATH).
|
--prefix PATH Override CMAKE_INSTALL_PREFIX (updates conf/config.sh BINPATH).
|
||||||
--dry-run Print commands without running them.
|
--dry-run Print commands without running them.
|
||||||
--run-after [CMD] Run shell command after successful compile. If CMD is omitted,
|
--restart Kill servers before compile, restart in tmux after.
|
||||||
uses FRACTURED_POST_UPDATE_CMD from the environment.
|
--run-after [CMD] Run a custom shell command after successful compile.
|
||||||
|
If CMD is omitted, uses FRACTURED_POST_UPDATE_CMD.
|
||||||
|
|
||||||
Environment:
|
Environment:
|
||||||
FRACTURED_GIT_REMOTE Git remote (default: origin).
|
FRACTURED_GIT_REMOTE Git remote (default: origin).
|
||||||
@@ -102,6 +105,10 @@ while [[ $# -gt 0 ]]; do
|
|||||||
DRY_RUN=1
|
DRY_RUN=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--restart)
|
||||||
|
DO_RESTART=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--run-after)
|
--run-after)
|
||||||
DO_RUN_AFTER=1
|
DO_RUN_AFTER=1
|
||||||
shift
|
shift
|
||||||
@@ -140,6 +147,18 @@ fi
|
|||||||
|
|
||||||
cd "$ROOT"
|
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
|
if [[ -n "$INSTALL_PREFIX" ]]; then
|
||||||
echo "==> updating conf/config.sh BINPATH to: $INSTALL_PREFIX"
|
echo "==> updating conf/config.sh BINPATH to: $INSTALL_PREFIX"
|
||||||
if grep -q '^BINPATH=' conf/config.sh; then
|
if grep -q '^BINPATH=' conf/config.sh; then
|
||||||
@@ -189,6 +208,11 @@ else
|
|||||||
run ./acore.sh compiler build
|
run ./acore.sh compiler build
|
||||||
fi
|
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
|
if [[ "$DO_RUN_AFTER" -eq 1 ]]; then
|
||||||
echo "==> post-update: $POST_UPDATE_CMD"
|
echo "==> post-update: $POST_UPDATE_CMD"
|
||||||
if [[ "$DRY_RUN" -eq 1 ]]; then
|
if [[ "$DRY_RUN" -eq 1 ]]; then
|
||||||
@@ -199,4 +223,8 @@ if [[ "$DO_RUN_AFTER" -eq 1 ]]; then
|
|||||||
fi
|
fi
|
||||||
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