fix: stabilize green-blue deploy verification
TaxBaik CI/CD / build-and-deploy (push) Failing after 8m16s
TaxBaik CI/CD / build-and-deploy (push) Failing after 8m16s
This commit is contained in:
+41
-2
@@ -48,17 +48,56 @@ if [ ! -s "$DEPLOY_DIR/proxy/TaxBaik.Proxy.dll" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
is_taxbaik_proxy_on_5001() {
|
||||
local pids
|
||||
pids=$(ss -tlnp 2>/dev/null | grep ':5001 ' | grep -oP 'pid=\K\d+' | sort -u || true)
|
||||
[ -n "$pids" ] || return 1
|
||||
|
||||
for pid in $pids; do
|
||||
if tr '\0' ' ' < "/proc/$pid/cmdline" 2>/dev/null | grep -q 'TaxBaik.Proxy.dll'; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# 0. Ensure the local TCP proxy exists and is running.
|
||||
# Nginx and external traffic always enter through 127.0.0.1:5001.
|
||||
if ! ss -tln | grep -q ':5001 '; then
|
||||
if ss -tln | grep -q ':5001 ' && ! is_taxbaik_proxy_on_5001; then
|
||||
echo "⚠️ Port 5001 is occupied by a non-proxy process. Attempting to stop legacy taxbaik.service..."
|
||||
echo " Current listener:" >&2
|
||||
ss -tlnp 2>/dev/null | grep ':5001 ' >&2 || true
|
||||
|
||||
if command -v systemctl >/dev/null 2>&1 && systemctl is-active --quiet taxbaik 2>/dev/null; then
|
||||
if command -v sudo >/dev/null 2>&1 && sudo -n true 2>/dev/null; then
|
||||
sudo -n systemctl stop taxbaik || true
|
||||
sudo -n systemctl disable taxbaik || true
|
||||
sleep 2
|
||||
else
|
||||
echo " sudo -n is unavailable; cannot stop legacy taxbaik.service automatically." >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
if ss -tln | grep -q ':5001 ' && ! is_taxbaik_proxy_on_5001; then
|
||||
echo "❌ Port 5001 is still occupied by a non-proxy process. Abort deploy to avoid routing traffic to the wrong app." >&2
|
||||
echo " Expected: TaxBaik.Proxy.dll on 127.0.0.1:5001" >&2
|
||||
echo " Manual fix: sudo systemctl stop taxbaik && sudo systemctl disable taxbaik" >&2
|
||||
ss -tlnp 2>/dev/null | grep ':5001 ' >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! is_taxbaik_proxy_on_5001; then
|
||||
echo "=== Starting proxy on 127.0.0.1:5001 ==="
|
||||
cd "$DEPLOY_DIR/proxy"
|
||||
nohup /usr/bin/dotnet TaxBaik.Proxy.dll > "$DEPLOY_HOME/taxbaik_proxy.log" 2>&1 &
|
||||
sleep 2
|
||||
fi
|
||||
|
||||
if ! ss -tln | grep -q ':5001 '; then
|
||||
if ! is_taxbaik_proxy_on_5001; then
|
||||
echo "❌ Proxy on 127.0.0.1:5001 is not running. Abort deploy." >&2
|
||||
ss -tlnp 2>/dev/null | grep ':5001 ' >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user