sdtaylor / GrassForecasts

0 stars 0 forks source link

dash setup on vps #13

Open sdtaylor opened 4 years ago

sdtaylor commented 4 years ago

Create a virtual environment

conda create -n grassforecasts python=3.7
conda activate grassforecasts
conda install pandas gunicorn dash numpy geopandas

Create /etc/systemd/system/gunicorn_grassforecasts.socket

[Unit]
Description=gunicorn socket for grassforecasts.info

[Socket]
ListenStream=/run/gunicorn_grassforecasts.sock

[Install]
WantedBy=sockets.target

Create /etc/systemd/system/gunicorn_grassforecasts.service

[Unit]
Description=gunicorn daemon for grassforecasts.info
Requires=gunicorn_grassforecasts.socket
After=network.target

[Service]
User=shawn
Group=www-data
WorkingDirectory=/home/shawn/projects/GrassForecasts
ExecStart=/home/shawn/miniconda3/envs/grassforecasts/bin/gunicorn \
          --access-logfile - \
          --workers 2 \
          --bind unix:/run/gunicorn_grassforecasts.sock \
          dash_test:server

[Install]
WantedBy=multi-user.target

run

sudo systemctl start gunicorn_grassforecasts.socket
sudo systemctl enable gunicorn_grassforecasts.socket

sudo systemctl start gunicorn_grassforecasts.service
sudo systemctl enable gunicorn_grassforecasts.service

Create /etc/nginx/sites-available/grassforecasts

server {
    server_name  grassland-forecast.com;

    location = /favicon.ico { access_log off; log_not_found off; }

    location /static/ {
        root /home/shawn/projects/GrassForecasts/;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn_grassforecasts.sock;
    }

}

run

sudo ln -s /etc/nginx/sites-available/grassforecasts /etc/nginx/sites-enabled/
sdtaylor commented 4 years ago

relevant tutorials
https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-16-04
https://markobigdata.com/2019/12/05/nginx-gunicorn-and-dash-on-centos/