'How To Deploy an Update to Python Flask Application with Gunicorn and Nginx on Ubuntu 18.04

Python Flask / Gunicorn / Nginx newbie here.

I followed this tutorial describing how to serve Flask Applications with Gunicorn and Nginx on Ubuntu 18.04.

Everything works and is up and running, no problem. However, my challenge is now that I would like to deploy an updated myproject.py file containing new code edits to the server. My question is do I simply just need to copy-paste the updated myproject.py file into the myproject folder such that it overwrites the old myproject.py file, and then the server will pick up these changes automatically? Or is there any specific commands I need to run for the changes to take effect or anything else I need to modify? What is the process for adding updated code?



Solution 1:[1]

You need to restart the gunicorn service that you created in /etc/systemd/system/myproject.service

sudo systemctl restart myproject

Solution 2:[2]

And you can use these:

sudo systemctl daemon-reload
sudo systemctl restart gunicorn

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 NavaneethaKrishnan
Solution 2 reza_khalafi