Код: Выделить всё
import py_eureka_client.eureka_client as eureka_client
import uvicorn
from fastapi import FastAPI
from contextlib import asynccontextmanager
from com.controladores import controladorRouter
@asynccontextmanager
async def lifespan(app: FastAPI):
await eureka_client.init_async(
eureka_server="http://eureka-primary:8011/eureka/,http://eureka-secondary:8012/eureka/,http://eureka-tertiary:8013/eureka/",
app_name="msprueba",
instance_port=8000,
instance_host="localhost"
)
yield
app = FastAPI(lifespan=lifespan)
app.include_router(controladorRouter)
if __name__ == "__main__":
config = uvicorn.Config("com.main:app", host="localhost", port=0)
server = uvicorn.Server(config)
server.run()
Подробнее здесь: https://stackoverflow.com/questions/782 ... and-eureka