#!/bin/bash set -euo pipefail umask 0027 # BaoTa sends SIGTERM and immediately starts the replacement. go-zero drains # existing connections asynchronously, so wait for the old listener to close. for attempt in $(seq 1 120); do if ! /usr/sbin/ss -H -ltn 'sport = :18888' | /usr/bin/grep -q .; then exec /www/server/xingyu-im/bt/xingyu-api fi sleep 0.25 done printf '%s\n' 'Cannot start Xingyu: local port 18888 is still occupied after 30 seconds.' >&2 exit 1