server startup
This commit is contained in:
parent
6c9891f268
commit
3367a01419
1 changed files with 6 additions and 4 deletions
10
src/main.py
10
src/main.py
|
|
@ -228,6 +228,11 @@ def create_app():
|
|||
app = Starlette(debug=True, routes=routes)
|
||||
app.state.services = services # Store services for cleanup
|
||||
|
||||
# Add startup event handler
|
||||
@app.on_event("startup")
|
||||
async def startup_event():
|
||||
await init_index()
|
||||
|
||||
# Add shutdown event handler
|
||||
@app.on_event("shutdown")
|
||||
async def shutdown_event():
|
||||
|
|
@ -286,10 +291,7 @@ if __name__ == "__main__":
|
|||
# Create app
|
||||
app = create_app()
|
||||
|
||||
# Run startup tasks
|
||||
asyncio.run(startup())
|
||||
|
||||
# Run the server
|
||||
# Run the server (startup tasks now handled by Starlette startup event)
|
||||
uvicorn.run(
|
||||
app,
|
||||
host="0.0.0.0",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue