diff --git a/hbd/client/main.py b/hbd/client/main.py index ea3f230..15ee92f 100644 --- a/hbd/client/main.py +++ b/hbd/client/main.py @@ -463,7 +463,7 @@ async def cleanup(connections: List[AsyncConnection]): logger.info("Cleaning up connections") target = next((c for c in connections if c.transport), connections[0] if connections else None) - if target: + if target and send_shutdown: try: await target.sendto({"shutdown": 1, "acks": target.ackcount}) except Exception as e: @@ -477,7 +477,7 @@ async def cleanup(connections: List[AsyncConnection]): async def async_main(args, config): """Async main function.""" - global running, shutdown_event, active_tasks + global running, shutdown_event, active_tasks, send_shutdown # Create shutdown event shutdown_event = asyncio.Event() @@ -525,10 +525,13 @@ async def async_main(args, config): logger.info(f"Created {len(connections)} connections") # Send boot/message if requested + send_shutdown = False if args.boot or args.message: boot_msg = {} if args.boot: boot_msg["boot"] = 1 + args.boot = False # Clear boot flag so we don't send it again in main loop + send_shutdown = True if args.message: boot_msg["service"] = "service" boot_msg["msg"] = args.message