How to Run Python Script in PM2 Server
To run your Flask app with PM2, follow these steps: Navigate to your project directory : Open your terminal and navigate to the directory containing your Flask app. cd path/to/flask_app Start your Flask app with PM2 : Use the following command to start your app with PM2. You need to specify the Python interpreter and the path to your app.py file. pm2 start app.py --interpreter python3 --name flask_app Replace python3 with your specific Python version if needed. Configure PM2 to run on startup (optional but recommended): To ensure PM2 restarts your app after a server reboot, you can set it up to run on startup with: pm2 startup Follow the instructions that PM2 provides after running this command. Save the PM2 process list : Save the current process list so that PM2 can restore it on reboot: pm2 save Check the status of your app : You can check the status of your Flask app using: pm2 list View logs : To see the logs for your Flask app, you can use: pm2 logs flask_app Now your...
Comments
Post a Comment