简体   繁体   中英

how to keep running my fastapi app even I close my aws terminal

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;    
    }
}

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 (eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM