Skip to content

Instantly share code, notes, and snippets.

@SRatna
Created June 27, 2017 05:47
Show Gist options
  • Save SRatna/f09dd67a1d3bcf7c886b5f7aa21976e0 to your computer and use it in GitHub Desktop.
Save SRatna/f09dd67a1d3bcf7c886b5f7aa21976e0 to your computer and use it in GitHub Desktop.
Steps I followed to set up gunicorn service in ubuntu for flask restless
I used anaconda as my python vendor.
So first install anaconda.
Then set path in .profile in home directory.
--> PATH="$HOME/bin:$HOME/.local/bin:$HOME/anaconda3/bin:$PATH"
then create a virtual environment using conda as
: conda create --name your_name_for_env python=3.4
this will create named env directory inside anaconda3/envs
do source activate your_name_for_env
now go to your project directory and install dependencies using pip as:
--> pip install -r requirements.txt
you must include gunicorn in your requirements.txt as we r establishing gunicorn sevice
Now you are ready to write gunicorn
do this:
-> sudo nano /etc/systemd/system/gunicorn.service
example for the service:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=alpha
Group=www-data
WorkingDirectory=/home/alpha/fms-backend-flask-restless
ExecStart=/home/alpha/anaconda3/envs/flask_rest_fms/bin/gunicorn --access-logfile - --workers 4 --bind 192.168.1.236:9090 api:app
[Install]
WantedBy=multi-user.target
now do:
sudo systemctl start gunicorn
sudo systemctl enable gunicorn
@ljtetris
Copy link

It's very clear and work very well, thanks!

@SRatna
Copy link
Author

SRatna commented Jul 28, 2023

Glad it helped you, I did it long time ago :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment