Skip to content

Commit a0a8d32

Browse files
committed
fix: clean up stale BullMQ/Redis data and improve process termination in bbdev
1 parent c909e64 commit a0a8d32

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

api/steps/sardine/01_run_event_step.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def handler(data, context):
2929

3030
sardine_dir = f"{bbdir}/bb-tests/sardine"
3131

32-
command = f"python3 run_tests.py --allure -m \"({data.get('workload', '')})\""
32+
command = f"python3 run_tests.py -m \"({data.get('workload', '')})\""
3333
context.logger.info(
3434
"Executing sardine command", {"command": command, "cwd": sardine_dir}
3535
)

api/steps/verilator/04_sim_event_step.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ async def handler(data, context):
4040
)
4141

4242
binary_path = search_workload(f"{bbdir}/bb-tests/output/workloads/src", binary_name)
43+
context.logger.info(f"binary_path: {binary_path}")
4344
success_result, failure_result = await check_result(
4445
context, returncode=(binary_path == None), continue_run=True
4546
)

bbdev

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import sys
44
import argparse
55
import subprocess
66
import os
7+
import signal
78
import shlex
89
import json
910
import time
11+
import shutil
1012
import requests
1113

1214
from utils import find_available_port
@@ -441,6 +443,11 @@ if __name__ == "__main__":
441443
"uvm",
442444
"palladium",
443445
]:
446+
# 0. Clean up stale BullMQ/Redis data to prevent replaying old events
447+
aof_dir = os.path.join(workflow_dir, ".motia", "appendonlydir")
448+
if os.path.exists(aof_dir):
449+
shutil.rmtree(aof_dir)
450+
444451
# 1. Start service in background ================================
445452
# If port is specified, use the specified port; otherwise, automatically assign port
446453
if args.port:
@@ -451,7 +458,8 @@ if __name__ == "__main__":
451458
proc = subprocess.Popen(
452459
["pnpm", "dev", "--port", str(available_port)],
453460
cwd=workflow_dir,
454-
stderr=subprocess.DEVNULL # Suppress stderr to hide BullMQ errors
461+
stderr=subprocess.DEVNULL, # Suppress stderr to hide BullMQ errors
462+
preexec_fn=os.setsid # Create new process group
455463
)
456464

457465
# Wait for service to start
@@ -479,7 +487,11 @@ if __name__ == "__main__":
479487
check=False,
480488
text=True,
481489
)
482-
proc.terminate()
490+
# Kill entire process group to clean up all child processes
491+
try:
492+
os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
493+
except ProcessLookupError:
494+
pass
483495
proc.wait()
484496
sys.exit(1)
485497

@@ -510,7 +522,8 @@ if __name__ == "__main__":
510522
# 3. Shutdown service ================================
511523
# Give observability plugin time to finish async operations (e.g., Redis writes)
512524
time.sleep(1)
513-
proc.terminate()
525+
# Kill entire process group (pnpm -> motia -> node) to avoid orphan processes
526+
os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
514527
proc.wait()
515528
print(
516529
f"\nTask completed. Command running on http://localhost:{available_port} is finished"

0 commit comments

Comments
 (0)