


Hosting Python Flask Applications as a service on Ubuntu Linux Server
Hosting Python Flask Applications as a service on Ubuntu Linux Server
Hosting Python Flask Applications as a service on Ubuntu Linux Server
Let us explore how to run Python Flask application as a Linux Service.

Let’s follow the below steps :
In order to deploy a service on Ubuntu server we need to create a file (name of the service : riiva) :
sudo nano /etc/system/system/riiva.service

2. Now, use the following caption :
[Unit] section:
Description=uWSGI instance to serve myproject
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/riva-stremingserver/
Environment=”PATH=/home/ubuntu/stream/bin”
ExecStart= gunicorn — bind 0.0.0.0:9501 -k flask_sockets.worker app:app
[Install]
WantedBy=multi-user.target

service file
3. Here the following terms included :
User:- The user is defined as the current user.
Group:- the user is in which group of linux.
WorkingDirectory:- It refers to the directory which you want to be worked on.
Environment:- It the takes the path of env where it can be run.
ExecStart:- It refers to the command which you want to execute.
4. After this, to start this service we have a command:
-> sudo systemctl start riiva

5. In order to see the status of logs of this service, we have a command:
sudo systemctl status riiva

6. Now to restart the service, we have a command:
sudo systemctl restart riiva

Your application is hosted upon HTTP://IP-ADDRESS:9501
7. Finally, to end this service, we have a command:
sudo systemctl stop riiva

Congratulations, You are done with the hosting.
For any further queries or anything related to Python Development, Coding, Blogging, Tech Documentation you can DM me on Linkedin or instagram at id=acanubhav94.
Let us explore how to run Python Flask application as a Linux Service.

Let’s follow the below steps :
In order to deploy a service on Ubuntu server we need to create a file (name of the service : riiva) :
sudo nano /etc/system/system/riiva.service

2. Now, use the following caption :
[Unit] section:
Description=uWSGI instance to serve myproject
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/riva-stremingserver/
Environment=”PATH=/home/ubuntu/stream/bin”
ExecStart= gunicorn — bind 0.0.0.0:9501 -k flask_sockets.worker app:app
[Install]
WantedBy=multi-user.target

service file
3. Here the following terms included :
User:- The user is defined as the current user.
Group:- the user is in which group of linux.
WorkingDirectory:- It refers to the directory which you want to be worked on.
Environment:- It the takes the path of env where it can be run.
ExecStart:- It refers to the command which you want to execute.
4. After this, to start this service we have a command:
-> sudo systemctl start riiva

5. In order to see the status of logs of this service, we have a command:
sudo systemctl status riiva

6. Now to restart the service, we have a command:
sudo systemctl restart riiva

Your application is hosted upon HTTP://IP-ADDRESS:9501
7. Finally, to end this service, we have a command:
sudo systemctl stop riiva

Congratulations, You are done with the hosting.
For any further queries or anything related to Python Development, Coding, Blogging, Tech Documentation you can DM me on Linkedin or instagram at id=acanubhav94.
Let us explore how to run Python Flask application as a Linux Service.

Let’s follow the below steps :
In order to deploy a service on Ubuntu server we need to create a file (name of the service : riiva) :
sudo nano /etc/system/system/riiva.service

2. Now, use the following caption :
[Unit] section:
Description=uWSGI instance to serve myproject
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/riva-stremingserver/
Environment=”PATH=/home/ubuntu/stream/bin”
ExecStart= gunicorn — bind 0.0.0.0:9501 -k flask_sockets.worker app:app
[Install]
WantedBy=multi-user.target

service file
3. Here the following terms included :
User:- The user is defined as the current user.
Group:- the user is in which group of linux.
WorkingDirectory:- It refers to the directory which you want to be worked on.
Environment:- It the takes the path of env where it can be run.
ExecStart:- It refers to the command which you want to execute.
4. After this, to start this service we have a command:
-> sudo systemctl start riiva

5. In order to see the status of logs of this service, we have a command:
sudo systemctl status riiva

6. Now to restart the service, we have a command:
sudo systemctl restart riiva

Your application is hosted upon HTTP://IP-ADDRESS:9501
7. Finally, to end this service, we have a command:
sudo systemctl stop riiva

Congratulations, You are done with the hosting.
For any further queries or anything related to Python Development, Coding, Blogging, Tech Documentation you can DM me on Linkedin or instagram at id=acanubhav94.