-1

I deploy my fast api on aws ec2 but the problem is I need to manually run python3 -m uvicorn main:app for start my fastapi app and if I close the terminal my fastapi app are not accessible from aws public ip.

here is ngnix config:

server {
    listen 80;   
    server_name aws ip;    
    location / {        
        proxy_pass http://127.0.0.1:8000;    
    }
}
jabodom934
  • 43
  • 1
  • 7
  • If you don't want to go down the ECS route, using`supervisord` or configuring `systemd` is a more resilient configuration than using screen or tmux - it'll handle restarts of the server and the application properly as well. – MatsLindh Oct 08 '22 at 06:49

1 Answers1

1

You can use tmux or screen to start a long running process as described here: keep server running on EC2 instance after ssh is terminated.

These sessions will persist even after the terminal is closed.

If you need a more resilient solution (e.g. automatic restarts on failure, logging, etc.), I would look into using AWS Elastic Container Service (ECS). This will handle scaling, restarts, logging, and much more.

Jeremypleb
  • 51
  • 1
  • 3