Handle keyboard interrupt
This commit is contained in:
parent
18e1e79598
commit
03b2b20ae2
1 changed files with 16 additions and 7 deletions
|
|
@ -96,12 +96,21 @@ class HaikuRAGApp:
|
||||||
"""Start the MCP server."""
|
"""Start the MCP server."""
|
||||||
async with HaikuRAG(self.db_path) as client:
|
async with HaikuRAG(self.db_path) as client:
|
||||||
monitor = FileWatcher(paths=Config.MONITOR_DIRECTORIES, client=client)
|
monitor = FileWatcher(paths=Config.MONITOR_DIRECTORIES, client=client)
|
||||||
asyncio.create_task(monitor.observe())
|
monitor_task = asyncio.create_task(monitor.observe())
|
||||||
server = create_mcp_server(self.db_path)
|
server = create_mcp_server(self.db_path)
|
||||||
|
|
||||||
if transport == "stdio":
|
try:
|
||||||
await server.run_stdio_async()
|
if transport == "stdio":
|
||||||
elif transport == "sse":
|
await server.run_stdio_async()
|
||||||
await server.run_sse_async("sse")
|
elif transport == "sse":
|
||||||
else:
|
await server.run_sse_async("sse")
|
||||||
await server.run_http_async("streamable-http")
|
else:
|
||||||
|
await server.run_http_async("streamable-http")
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
monitor_task.cancel()
|
||||||
|
try:
|
||||||
|
await monitor_task
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
pass
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue