fix: prune data and system before starting
This commit is contained in:
parent
d79017b09d
commit
3e88a314d8
1 changed files with 6 additions and 5 deletions
|
|
@ -35,6 +35,12 @@ async def lifespan(app: FastAPI):
|
||||||
from cognee.infrastructure.databases.relational import create_db_and_tables
|
from cognee.infrastructure.databases.relational import create_db_and_tables
|
||||||
|
|
||||||
# Not needed if you setup a migration system like Alembic
|
# Not needed if you setup a migration system like Alembic
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
from cognee.modules.data.deletion import prune_system, prune_data
|
||||||
|
asyncio.run(prune_data())
|
||||||
|
asyncio.run(prune_system(metadata = True))
|
||||||
|
|
||||||
await create_db_and_tables()
|
await create_db_and_tables()
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
@ -388,11 +394,6 @@ def start_api_server(host: str = "0.0.0.0", port: int = 8000):
|
||||||
try:
|
try:
|
||||||
logger.info("Starting server at %s:%s", host, port)
|
logger.info("Starting server at %s:%s", host, port)
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from cognee.modules.data.deletion import prune_system, prune_data
|
|
||||||
asyncio.run(prune_data())
|
|
||||||
asyncio.run(prune_system(metadata = True))
|
|
||||||
|
|
||||||
uvicorn.run(app, host = host, port = port)
|
uvicorn.run(app, host = host, port = port)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(f"Failed to start server: {e}")
|
logger.exception(f"Failed to start server: {e}")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue