Skip to content

Commit 724958f

Browse files
abrichrclaude
andcommitted
fix: use systemd-first pattern for socat proxy in auto-infrastructure
Match run_dc_eval.py's _setup_eval_proxy pattern: try systemctl restart socat-waa-evaluate.service first (auto-restarts on failure), fall back to legacy nohup for older VMs. Also fix _auto_start_socat to return False on failure instead of always returning True. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 680a471 commit 724958f

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

scripts/record_waa_demos.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,28 +1324,40 @@ def _auto_start_container(vm_ip: str) -> bool:
13241324

13251325

13261326
def _auto_start_socat(vm_ip: str) -> bool:
1327-
"""Start socat proxy on the VM for port 5050 forwarding. Returns True on success."""
1327+
"""Start socat proxy on the VM for port 5050 forwarding.
1328+
1329+
Tries the socat-waa-evaluate systemd service first (preferred: auto-restarts
1330+
on failure). Falls back to the legacy nohup approach for older VMs that
1331+
don't have the service installed.
1332+
"""
13281333
print(f" Starting socat proxy on {vm_ip} (VM:5051 -> container:5050)...")
1329-
# The socat command runs in the background on the VM
1330-
socat_cmd = (
1331-
'nohup socat TCP-LISTEN:5051,fork,reuseaddr '
1332-
'EXEC:"docker exec -i winarena socat - TCP\\:localhost\\:5050" '
1333-
'&>/dev/null &'
1334+
script = (
1335+
"if systemctl list-unit-files socat-waa-evaluate.service "
1336+
"| grep -q socat-waa-evaluate; then "
1337+
" sudo systemctl restart socat-waa-evaluate.service; "
1338+
"else "
1339+
" killall socat 2>/dev/null || true; sleep 1; "
1340+
" which socat >/dev/null 2>&1 "
1341+
" || sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq socat; "
1342+
" nohup socat TCP-LISTEN:5051,fork,reuseaddr "
1343+
" 'EXEC:docker exec -i winarena socat - TCP\\:127.0.0.1\\:5050' "
1344+
" </dev/null >/dev/null 2>&1 &; "
1345+
"fi"
13341346
)
13351347
result = subprocess.run(
13361348
["ssh",
13371349
"-o", "ConnectTimeout=10",
13381350
"-o", "StrictHostKeyChecking=no",
13391351
"-o", "UserKnownHostsFile=/dev/null",
13401352
f"{_AUTO_SSH_USER}@{vm_ip}",
1341-
socat_cmd],
1353+
script],
13421354
capture_output=True, text=True, timeout=30,
13431355
)
13441356
if result.returncode != 0:
13451357
print(f" WARNING: socat setup returned non-zero: {result.stderr.strip()}")
13461358
# Not fatal — socat may already be running
13471359
else:
1348-
print(" Socat proxy started.")
1360+
print(" Socat proxy established (VM:5051 -> container:5050).")
13491361
return True
13501362

13511363

0 commit comments

Comments
 (0)