I have small app created on python flask and deployed on EC2 aws machine, when I do ssh to ec2 machine and starts flask, it works, but when I terminate the session the flask dies, I can run it using nohup. What is the best way to make it independent of ssh session and run it continuously.
To install flask, simply type in pip install flask in your computer terminal/command line. Once you have made sure flask is installed, simply run the hello.py script. Once you run the script, the website should now be up and running on your local machine, and it can be viewed by visiting localhost:5000 in your browser.
Installing Python on AWS EC2 : Follow the below steps to install Python on AWS EC2: Step 1: Create an AWS Elastic Cloud Compute Instance. Step 2: Start the EC2 instance that you have created in Step 1. Step 3: Connect to your EC2 Instance by clicking on Connect Button.
There are several options:
nohup python app.py &
screen
supervisord
(link) on system startup and control all through it (pythonic way :))nohup means: do not terminate this process even when the stty is cut off.
& at the end means: run this command as a background task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With