refactor: improve stream cleanup before system reboot by closing WebRTC connections and stopping multicasters
This commit is contained in:
@@ -594,11 +594,23 @@ async def system_reboot():
|
||||
Requires the service user to have passwordless sudo permissions to run 'reboot'.
|
||||
"""
|
||||
try:
|
||||
# Best-effort: stop any active streaming cleanly
|
||||
# Best-effort: stop any active streaming cleanly WITHOUT persisting state
|
||||
try:
|
||||
await stop_audio()
|
||||
# Close any WebRTC peer connections
|
||||
close_tasks = [pc.close() for pc in list(pcs)]
|
||||
pcs.clear()
|
||||
if close_tasks:
|
||||
await asyncio.gather(*close_tasks, return_exceptions=True)
|
||||
|
||||
# Stop streaming on multicasters but DO NOT touch stream_settings.json
|
||||
if multicaster1 is not None:
|
||||
await multicaster1.stop_streaming()
|
||||
await multicaster1.shutdown()
|
||||
if multicaster2 is not None:
|
||||
await multicaster2.stop_streaming()
|
||||
await multicaster2.shutdown()
|
||||
except Exception:
|
||||
log.warning("Failed to stop audio before reboot", exc_info=True)
|
||||
log.warning("Non-fatal: failed to stop streams before reboot", exc_info=True)
|
||||
|
||||
# Launch reboot without waiting for completion
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user