File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -207,11 +207,25 @@ async def health_check(request):
207207 await site .start ()
208208 logger .info ('Health check server started on http://localhost:8080/health' )
209209
210+ # Keep the server alive until shutdown
211+ try :
212+ await asyncio .Future () # Placeholder to keep the server running
213+ except asyncio .CancelledError :
214+ logger .info ("HTTP server shutdown initiated." )
215+ finally :
216+ await runner .cleanup () # Cleanup on shutdown
217+
218+
210219async def ffmpeg_server ():
211220 grpc_task = asyncio .create_task (start_grpc_server ())
212- http_task = asyncio .create_task (start_http_server ())
213221 health_task = asyncio .create_task (health_check_runner ())
214- await asyncio .gather (grpc_task , http_task , health_task )
222+ http_task = asyncio .create_task (start_http_server ()) # Treat HTTP server as a task
223+
224+ try :
225+ await asyncio .gather (grpc_task , health_task , http_task )
226+ except asyncio .CancelledError :
227+ logger .info ("Server tasks canceled. Cleaning up..." )
228+ raise
215229
216230def handle_signals ():
217231 loop = asyncio .get_event_loop ()
You can’t perform that action at this time.
0 commit comments