Add README and conf files for prod deploy

bootstrap
Pete Ley 9 months ago
parent 173b0a4805
commit 9b388e1bf0

@ -0,0 +1,64 @@
# dwgstatus #
dwgstatus is a Django app to manage the detailing department's drawings
## Set up dev server ##
`$ ` is a user prompt
`# ` is a root prompt
- mount the P: drive at /mnt/p
```
# apt install cifs-utils
# mkdir -p /mnt/p
# mount -t cifs "//psc-3/Project Management" /mnt/p -o user=<YOUR USER NAME>
```
- clone repo to your home drive and switch to repo directory
```
$ git clone https://gitlab.com/pacstair/dwgstatus ~/dwgstatus
$ cd ~/dwgstatus
```
- create and activate virtual env
```
$ python -m venv venv
$ . venv/bin/activate
```
- install required python packages
```
$ pip install -r requirements.txt
```
- optionally, copy the `db.sqlite3` file to `~/dwgstatus` from a backup
- run DB migrations
```
$ python manage.py migrate
```
- run dev server
```
$ python manage.py runserver
```
Dev server should now be running at http://localhost:8000
Changes to most files will be picked up and the server restarted
automatically when you edit a file.
## Deploy to prod ##
See above for steps not explained here. Assuming a fresh debian
install:
- mount P: drive to /mnt/p
- create user `dwgstatus`
- as user `dwgstatus`,
- clone repo to `~/dwgstatus`
- create venv and install python packages
- install required debian packages:
- nginx
- uwsgi
- uwsgi-emperor
- copy `nginx.conf` to `/etc/nginx/sites-available/dwgstatus`
- symlink `/etc/nginx/sites-available/dwgstatus` to `/etc/nginx/sites-enabled/dwgstatus`
- restart nginx
`systemctl restart nginx`
- delete `/etc/uwsgi-emperor/emperor.ini` and replace with `~/dwgstatus/uwsgi-emperor.ini`
- symlink `~/dwgstatus/uwsgi.ini` to `/etc/uwsgi-emperor/vassals/dwgstatus.ini`

@ -0,0 +1,4 @@
from .settings import *
DEBUG = False

@ -0,0 +1,22 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
location /p/ {
root /mnt;
autoindex on;
autoindex_format xml;
xslt_stylesheet /var/www/autoindex.xslt;
}
location /static/ {
root /home/dwgstatus/dwgstatus;
}
location / {
uwsgi_pass unix:///tmp/dwgstatus.sock;
include uwsgi_params;
}
}

@ -0,0 +1,6 @@
asgiref==3.7.2
Django==4.2.4
localflavor==1.9
pymemcache==4.0.0
six==1.16.0
sqlparse==0.4.4

@ -0,0 +1,24 @@
[uwsgi]
# enable master process manager
master = true
# spawn 2 uWSGI emperor worker processes
workers = 2
# automatically kill workers on master's death
no-orphans = true
# place timestamps into log
log-date = true
# user identifier of uWSGI processes
uid = dwgstatus
# group identifier of uWSGI processes
gid = dwgstatus
# vassals directory
emperor = /etc/uwsgi-emperor/vassals
plugins=python3

@ -0,0 +1,10 @@
[uwsgi]
chdir=/home/dwgstatus/dwgstatus
home=/home/dwgstatus/dwgstatus/venv
module=dwgstatus.wsgi:application
env=DJANGO_SETTINGS_MODULE=dwgstatus.prodsettings
socket=/tmp/dwgstatus.sock
plugins=python3
pidfile=/tmp/dwgstatus.pid
vacuum=True
daemonize=/home/dwgstatus/dwgstatus/dwgstatus.log
Loading…
Cancel
Save