#!/bin/sh # (Re)starts the sbtest cluster in order db, auth, channel5 (README.md). Restarting empties the db cache, # so the next login reads everything from MySQL. set -eu R=/usr/metin2/server T=$R/sbtest C5=$R/channel5/first grep -q '^DB_PORT: 15040' $C5/CONFIG || { echo "channel5 is not on the sbtest db; run setup.sh" >&2; exit 1; } for d in $C5 $T/auth $T/db; do [ -f $d/pid ] || continue p=$(cat $d/pid) kill -0 "$p" 2>/dev/null || continue kill -1 "$p" i=0; while kill -0 "$p" 2>/dev/null && [ $i -lt 40 ]; do sleep 1; i=$((i+1)); done echo "$d stopped after ${i}s" done daemon -f sh -c "cd $T/db && exec ./db > stdout 2>&1"; sleep 6 daemon -f sh -c "cd $T/auth && exec ./auth > stdout 2>&1"; sleep 4 daemon -f sh -c "cd $C5 && exec ./game > stdout 2>&1"; sleep 12 sockstat -l | grep -E ':(15040|11040|12040|13040|14040) ' echo "live db/auth listening: $(sockstat -l | grep -c -E ':(15000|11000) ') (expect 2)"