play
Deploy FastAPI on Ubuntu (FastAPI + CRUD + PostgreSQL + Gunicorn + Systemd + Caddy 2)
1K views · Feb 16, 2022
Visit Channel:publisher-humix
Detailed Step by step Article: https://bit.ly/2SGLWgt (Deploy FastAPI on Ubuntu and Serve using Caddy 2 Web Server)

Author: Navule Pavan Kumar Rao

This is deployment tutorial. If you are interested in Development, please refer Implementing Async REST APIs in Python using FastAPI with PostgreSQL CRUD : https://bit.ly/3j42qvf 
(っ◔◡◔)っ ♥░-░-░-░-░-░-░-░-░-This tutorial has 5 steps.░-░-░-░-░-░-░-░-░-░-♥


Step 1: Ubuntu 18 VM Creation on Azure
Step 2: PostgreSQL Database Configuration
Step 3: Setup Deployment of FastAPI
Step 4: Configure Gunicorn as Systemd unit service
Step 5: Install and Configure Caddy 2 Web Server

????????:
???? ?: ?????? ?? ?? ???????? ?? ?????
------------------------------------------------------------------------
(00:00) Introduction
(00:50) Create Ubuntu 18 Virtual Machine on Azure

???? ?: ?????????? ???????? ?????????????
------------------------------------------------------------------------
(06:58) Install PostgreSQL 13.1 on Ubuntu 18
(08:36) Configure PostgreSQL 13.1 on Ubuntu 18

???? ?: ????? ?????????? ?? ???????
------------------------------------------------------------------------
(10:43) Deploy FastAPI on Ubuntu
(12:40) Setup ? Virtual Environment
(14:39) Install Requirements

???? ?: ????????? ???????? ?? ??????? ???? ???????
----------------------------------------------------------------------------------
(17:05) Run FastAPI on Gunicorn as a Systemd Managed Unit Service
(27:53) Rotating Gunicorn accesslog and errorlog files using logrotate

???? ?: ??????? ??? ????????? ????? ? ??? ??????
------------------------------------------------------------------------
(30:28) Install Caddy 2 Web Server on Ubuntu
(35:44) Configure Caddyfile with Custom Domain and HTTPS using Caddy 2
(39:36) Real Demo accessing FastAPI REST Endpoints from custom domain

(っ◔◡◔)っ ♥░-░-░-░-░-░-░-░-???????????????░-░-░-░-░-░-░-░-░-░-░-♥

????? ?????? ????? ??? ??????????????? ??????????
To ensure our deployment is up and running again, reboot the VM and browse the http://IPAddress/notes/. You should be able to see the notes collection.

If you didn’t see the response as expected, troubleshoot at each layer as described below.

???????????? ?????????? ?? ???????? ????????????

Check the status of PostgreSQL database server systemctl status postgresql
if its not active, then run sudo systemctl enable postgresql and sudo systemctl start postgresql
In case to look at the logs of PostgreSQL Service run the command journalctl --unit=postgresql
Check the database user and the database exists in PostgreSQL
Check the database user has all privileges on database
Check the connection string in FastAPI is properly built and is connecting to the installed PostgreSQL database.

??????????????? ???????? ???????

Check the status of Gunicon Service systemctl status gunicorn.service
If Gunicorn service is not active check the ExecStart, WorkingDirectory and Environment are properly configured with paths that actually exists in VM
To look at logs of gunicorn service run journalctl --unit=gunicorn

sudo systemctl daemon-reload
sudo systemctl enable gunicorn.service
sudo systemctl start gunicorn.service


???????????? ????? ? ??? ?????? ?????
Check the status of Caddy Service systemctl status caddy.service
In case to look at the logs of Caddy Service run the command "journalctl --unit=caddy"

If Caddy Service is not run then try running

sudo systemctl daemon-reload
sudo systemctl enable caddy
sudo systemctl start caddy

Ensure the /etc/caddy/Caddyfile is having correct url to reverse_proxy with url and port that matches the url and port in gunicorn.service file. In our case its 0.0.0.0:8000
Any changes made to the Caddyfile requires a restart of the Caddy Service in order for those changes to be effective.
Run the command caddy adapt --config /etc/caddy/Caddyfile --pretty that will hint any syntax errors in Caddyfile.
Run the command to restart Caddy Service sudo systemctl restart caddy and check the status of the caddy service systemctl status caddy.service


????? ??? ???? ?? ?? ???? ?????
You can disable password based SSH access once the deployment is successful by disabling Port 22 on the VM.

You can configure Continuous Integration and Continuous Deliver by adding GitHub web hooks that automatically push code or configure Travis to do the CI/CD for you.


#fastapi #gunicorn #ubuntu #devops
(っ◔◡◔)っ ♥░-░-░-░-░-░-░-░-░-???????░-░-░-░-░-░-░-░-░-░-♥
(Appreciate your Generosity ?)
PayPal: http://bit.ly/2NZgVma 
ETH: 0x0689Ecd747d6F4eA9CE491aD0b1734fEe62b2229

(っ◔◡◔)っ ♥░-░-░-░-░-░-░-░-░-?Subscribe?░-░-░-░-░-░-░-░-░-░-♥

????????? to ???????? channel if you like the content http://bit.ly/2Uc0YNk
?????????: http://bit.ly/2Uc0YNk

(っ◔◡◔)っ Share this video with your friends and colleagues and let them know you are up to date with latest tech-trends

Thanks ?

Follow us to keep updated with latest trends in Tech: 

Facebook: http://bit.ly/2Djmd6l
Twitter: http://bit.ly/2Ol9ZQT
Instagram: http://bit.ly/2pV4cYY
Show More

Comments

Recommended Videos
'Video thumbnail for How to Deploy FastAPI on Azure App Service in just 30 minutes'
33:09
play
How to Deploy FastAPI on Azure App Service in just 30 minutes
2K views · Feb 16, 2022
'Video thumbnail for Deploy FastAPI on Heroku in just 6 minutes'
6:37
play
Deploy FastAPI on Heroku in just 6 minutes
2K views · Feb 16, 2022
'Video thumbnail for Implementing Async REST APIs in Python using FastAPI with PostgreSQL CRUD'
39:56
play
Implementing Async REST APIs in Python using FastAPI with PostgreSQL CRUD
5K views · Feb 16, 2022
'Video thumbnail for Deploy FastAPI Python app to Google Cloud Platform on Google App Engine'
21:53
play
Deploy FastAPI Python app to Google Cloud Platform on Google App Engine
2K views · Feb 16, 2022
'Video thumbnail for How to deploy Machine Learning models using FastAPI from scratch'
16:25
play
How to deploy Machine Learning models using FastAPI from scratch
0 views · Aug 12, 2022
'Video thumbnail for Fast API Machine Learning Model Deploy on Heruko'
5:20
play
Fast API Machine Learning Model Deploy on Heruko
3 views · Aug 12, 2022
'Video thumbnail for Install NextCloud Container Using Portainer -1'
9:08
play
Install NextCloud Container Using Portainer -1
673 views · Aug 5, 2022
'Video thumbnail for How to deploy V lang REST API on Azure'
22:57
play
How to deploy V lang REST API on Azure
0 views · Sep 15, 2022
'Video thumbnail for Ansible Lab - Install Ansible and Run Simple Command Remotely'
13:04
play
Ansible Lab - Install Ansible and Run Simple Command Remotely
1K views · Aug 20, 2022