diff --git a/hbd/client/main.py b/hbd/client/main.py index 6885da1..641bcf3 100644 --- a/hbd/client/main.py +++ b/hbd/client/main.py @@ -486,7 +486,8 @@ 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 and send_shutdown: + # A SIGHUP restart is not a host shutdown, so don't announce one. + if target and send_shutdown and not dorestart: try: await target.sendto({"shutdown": 1, "acks": target.ackcount}) except Exception as e: @@ -564,7 +565,6 @@ async def async_main(args, config): 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" @@ -793,7 +793,10 @@ def main(argv=None): # Handle restart if dorestart: logging.info("Restarting...") - os.execv(sys.argv[0], sys.argv) + # Drop -b/--boot so the re-exec'd process doesn't re-announce a boot; + # a SIGHUP restart is not a host reboot. + restart_argv = [sys.argv[0]] + [a for a in sys.argv[1:] if a not in ("-b", "--boot")] + os.execv(restart_argv[0], restart_argv) sys.exit(exit_code)