minigame 2 just begin1.6
This commit is contained in:
@@ -5,10 +5,20 @@ set -euo pipefail
|
||||
REPO="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
SRC="$REPO/www/html/"
|
||||
DST="/var/www/html/"
|
||||
GAME_SERVER_JS="$DST/Game/server.js"
|
||||
if [[ "$(id -u)" -ne 0 ]]; then
|
||||
echo "Run as root: sudo $0" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ถ้า Game/server.js เปลี่ยนหลัง deploy — Node ต้องรีโหลดโค้ด (systemd: game-zep.service)
|
||||
hash_game_server_js() {
|
||||
local f="$1"
|
||||
[[ -f "$f" ]] || { echo ""; return 0; }
|
||||
sha256sum "$f" | awk '{print $1}'
|
||||
}
|
||||
GAME_SRV_HASH_BEFORE="$(hash_game_server_js "$GAME_SERVER_JS")"
|
||||
|
||||
rsync -a \
|
||||
--checksum \
|
||||
--exclude 'node_modules' \
|
||||
@@ -23,4 +33,15 @@ GA="$DST/Game/public/img/gauntlet-assets"
|
||||
mkdir -p "$GA"
|
||||
chown www-data:www-data "$GA"
|
||||
chmod 2775 "$GA"
|
||||
|
||||
GAME_SRV_HASH_AFTER="$(hash_game_server_js "$GAME_SERVER_JS")"
|
||||
if [[ -n "$GAME_SRV_HASH_AFTER" && "$GAME_SRV_HASH_BEFORE" != "$GAME_SRV_HASH_AFTER" ]]; then
|
||||
if systemctl cat game-zep.service &>/dev/null; then
|
||||
systemctl restart game-zep.service
|
||||
echo "OK: restarted game-zep.service (Game/server.js changed)"
|
||||
else
|
||||
echo "WARN: Game/server.js changed but no game-zep.service — restart Node manually" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "OK: deployed $SRC -> $DST (node_modules on server untouched)"
|
||||
|
||||
Reference in New Issue
Block a user