fix: wait for port to free after docker stop in debug mode

This commit is contained in:
admin 2026-08-08 05:31:29 +00:00
parent 853aad8a36
commit 79707c9395

View file

@ -407,6 +407,18 @@ def start_debug():
# Stop container, start tap
print(f"\nStopping wallarm-{n['name']}...")
run(f"docker stop wallarm-{n['name']} 2>/dev/null", timeout=10)
run(f"docker rm -f wallarm-{n['name']} 2>/dev/null", timeout=5)
# Wait for port to free
import time
for _ in range(10):
r = run(f"ss -tlnp | grep ':{port}' 2>/dev/null")
if not r.stdout.strip():
break
time.sleep(1)
else:
print(f"Port {port} still in use — killing...")
run(f"fuser -k {port}/tcp 2>/dev/null", timeout=5)
time.sleep(2)
print(f"Tap proxy :{port}{backend}")
print(f"Log: {logdir}/tap-*.log")
print("Press Ctrl+C to stop — container will restart automatically.\n")