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 = Starlette(debug=True, routes=routes)
|
||||||
app.state.services = services # Store services for cleanup
|
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
|
# Add shutdown event handler
|
||||||
@app.on_event("shutdown")
|
@app.on_event("shutdown")
|
||||||
async def shutdown_event():
|
async def shutdown_event():
|
||||||
|
|
@ -286,10 +291,7 @@ if __name__ == "__main__":
|
||||||
# Create app
|
# Create app
|
||||||
app = create_app()
|
app = create_app()
|
||||||
|
|
||||||
# Run startup tasks
|
# Run the server (startup tasks now handled by Starlette startup event)
|
||||||
asyncio.run(startup())
|
|
||||||
|
|
||||||
# Run the server
|
|
||||||
uvicorn.run(
|
uvicorn.run(
|
||||||
app,
|
app,
|
||||||
host="0.0.0.0",
|
host="0.0.0.0",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue