1

I have a fastapi service deployed on AWS, the API sends request to OpenAI API to generate text.

This API had been running fine for 2-3 days but now it keeps restarting on it's own after every 10 minutes. There are no errors or any helpful information in the AWS logs.

I also set request_timeout to 30 seconds in case this was happening because OpenAI API took too long to respond.

Any info about this is appreciated.

edit: start.sh file contains this line: python3 main.py

and main.py is as follows:

import uvicorn

if __name__ ="__main__":
   uvicorn.run("app.main:app, host="0.0.0.0", port=9026, reload=True)

Note: When the service is not being used the container does not restart, it only happens when requests are being made to the service that the container restarts every 10-20 minutes depending on the number of requests.

Deepali
  • 31
  • 2

2 Answers2

0

you need to try uvicorn app.main:app --reload --host 0.0.0.0 --port 9026 in bash script to run, It is just another way to run.

Shubham
  • 33
  • 5
0

Please check health check in Task Definition

Its mentioned here: uvicorn shutting down after 1-2 minutes on AWS Fargate