diff --git a/misc/kcdcpython.service b/misc/kcdcpython.service new file mode 100644 index 00000000..2a007721 --- /dev/null +++ b/misc/kcdcpython.service @@ -0,0 +1,15 @@ +[Unit] +Description=Runs the gunicorn process for KCDC website +After=nginx.service mysql.service + +[Service] +PIDFile=/srv/www/production/var/gunicorn.pid +Type=forking +User=www-data +Group=www-data +ExecStart=/bin/bash -c 'cd /srv/www/production && source venv/bin/activate ; /srv/www/production/manage.py run_gunicorn --pid=/srv/www/production/var/gunicorn.pid --access-logfile=/srv/www/production/var/access.log --error-logfile=/srv/www/production/var/error.log --log-level=INFO --bind=127.0.0.1:8000 --daemon' +TimeoutStopSec=10 +KillMode=mixed + +[Install] +WantedBy=multi-user.target diff --git a/misc/nginx-sites-enabled-kcdc.conf b/misc/nginx-sites-enabled-kcdc.conf index 3809949e..51a2dc87 100644 --- a/misc/nginx-sites-enabled-kcdc.conf +++ b/misc/nginx-sites-enabled-kcdc.conf @@ -1,37 +1,38 @@ upstream production_app_server { - server 127.0.0.1:8001 fail_timeout=0; + server 127.0.0.1:8000 fail_timeout=0; } server { - listen 80; ## listen for ipv4; this line is default and implied - client_max_body_size 4G; - server_name knowledgecommonsdc.org; + listen 80; ## listen for ipv4; this line is default and implied + client_max_body_size 4G; + server_name knowledgecommonsdc.org; - keepalive_timeout 5; + keepalive_timeout 5; - root /srv/www/production/kcdc/kcdc3/kcdc3/public; + root /srv/www/production/kcdc3/public; - - # I think this should be blank, to match anything + # I think this should be blank, to match anything location / { - try_files $uri @proxy_to_app; - } + try_files $uri @proxy_to_app; + } location = /static/ { - root /srv/www/production/kcdc/kcdc3/kcdc3/public/static; - expires 30d; # suggested, i guess we can do whenever + root /srv/www/production/kcdc3/public/static; + expires 30d; # suggested, i guess we can do whenever + } + + location @proxy_to_app { + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + + proxy_pass http://production_app_server; + } + + error_page 500 502 503 504 /500.html; + location /500.html { + root /srv/www/production/kcdc3/kcdc3/public; } - - location @proxy_to_app { - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - - proxy_pass http://production_app_server; - } - - error_page 500 502 503 504 /500.html; - location /500.html { - root /srv/www/production/kcdc3/kcdc3/public; - } + } +