feat: restart on SIGHUP in hbc and hbc_mini

Sets dorestart and triggers a clean shutdown; os.execv re-execs
the process with the original arguments after cleanup.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Andreas Wrede
2026-05-02 10:06:26 -04:00
parent 5523c60866
commit 2bd3a9beb6
2 changed files with 14 additions and 0 deletions
+7
View File
@@ -524,6 +524,13 @@ async def async_main(args, config):
loop = asyncio.get_event_loop()
for sig in (signal.SIGTERM, signal.SIGINT):
loop.add_signal_handler(sig, stop)
def _sighup():
global dorestart
dorestart = True
stop()
loop.add_signal_handler(signal.SIGHUP, _sighup)
# Start async tasks
# Heartbeat senders (one per connection)
+7
View File
@@ -1066,6 +1066,13 @@ async def _async_main(args, cfg: Dict[str, Any]) -> int:
for sig in (signal.SIGTERM, signal.SIGINT):
loop.add_signal_handler(sig, _stop)
def _sighup():
global _dorestart
_dorestart = True
_stop()
loop.add_signal_handler(signal.SIGHUP, _sighup)
for conn in connections:
_active_tasks.append(asyncio.create_task(_heartbeat_sender(conn, interval)))