mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-26 16:48:04 +00:00
Merge branch 'main' into acl-vector-stores
This commit is contained in:
commit
9a308e0ef1
1 changed files with 17 additions and 1 deletions
|
|
@ -597,7 +597,23 @@ def main(args: argparse.Namespace | None = None):
|
||||||
uvicorn_config.update(ssl_config)
|
uvicorn_config.update(ssl_config)
|
||||||
|
|
||||||
# Run uvicorn in the existing event loop to preserve background tasks
|
# Run uvicorn in the existing event loop to preserve background tasks
|
||||||
loop.run_until_complete(uvicorn.Server(uvicorn.Config(**uvicorn_config)).serve())
|
# We need to catch KeyboardInterrupt because uvicorn's signal handling
|
||||||
|
# re-raises SIGINT signals using signal.raise_signal(), which Python
|
||||||
|
# converts to KeyboardInterrupt. Without this catch, we'd get a confusing
|
||||||
|
# stack trace when using Ctrl+C or kill -2 (SIGINT).
|
||||||
|
# SIGTERM (kill -15) works fine without this because Python doesn't
|
||||||
|
# have a default handler for it.
|
||||||
|
#
|
||||||
|
# Another approach would be to ignore SIGINT entirely - let uvicorn handle it through its own
|
||||||
|
# signal handling but this is quite intrusive and not worth the effort.
|
||||||
|
try:
|
||||||
|
loop.run_until_complete(uvicorn.Server(uvicorn.Config(**uvicorn_config)).serve())
|
||||||
|
except (KeyboardInterrupt, SystemExit):
|
||||||
|
logger.info("Received interrupt signal, shutting down gracefully...")
|
||||||
|
finally:
|
||||||
|
if not loop.is_closed():
|
||||||
|
logger.debug("Closing event loop")
|
||||||
|
loop.close()
|
||||||
|
|
||||||
|
|
||||||
def _log_run_config(run_config: StackRunConfig):
|
def _log_run_config(run_config: StackRunConfig):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue