Created
June 27, 2017 05:47
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
It's very clear and work very well, thanks!