Update README to include better instructions

This commit is contained in:
Quantum 2024-04-13 01:00:28 -04:00
parent 2fa79c7782
commit 3ea6414c1e

View file

@ -10,11 +10,55 @@ bit of Django metaprogramming. PRs welcome!
## Installation ## Installation
1. Clone this repository: `git clone https://github.com/quantum5/peeringdb-mirror.git`; 1. Clone this repository: `git clone https://github.com/quantum5/peeringdb-mirror.git`;
2. Create a virtualenv: `python3 -m venv venv`; 2. Enter the cloned repo: `cd peeringdb-mirror`;
3. Install dependencies: `pip install -r requirements.txt`; 3. Create a virtualenv: `python3 -m venv venv`;
4. Configure Django: `cp peeringdb_mirror/settings/{template,local}.py` and edit 4. Activate the virtualenv for all subsequent commands: `. venv/bin/activate`;
5. Install dependencies: `pip install -r requirements.txt`;
6. Configure Django: `cp peeringdb_mirror/settings/{template,local}.py` and edit
`peeringdb_mirror/settings/local.py`. You should change `SECRET_KEY` and `peeringdb_mirror/settings/local.py`. You should change `SECRET_KEY` and
update `DATABASES`. See the linked Django documentation for details; update `DATABASES`. See the linked Django documentation for details;
5. Migrate database: `python manage.py migrate`; 7. Migrate database: `python manage.py migrate`;
6. Run the WSGI app `peeringdb_mirror.wsgi:application` with your favourite 8. Run initial database sync from PeeringDB: `python manage.py sync_peeringdb`;
WSGI-capable application server. and
9. Run the WSGI app `peeringdb_mirror.wsgi:application` with your favourite
WSGI-capable application server; and
10. Set up a cron job to run the `sync_peeringdb` command every hour:
`0 * * * * /path/to/venv/bin/python /path/to/repo/manage.py sync_peeringdb`.
## Example uWSGI configuration in production
If you choose to run uWSGI, you can use the following configuration provided
for your convenience:
```ini
[uwsgi]
uid = peeringdb
gid = peeringdb
protocol = uwsgi
; For TCP socket
socket = :1234
; For Unix socket, you can do
; socket = /tmp/peeringdb-mirror.sock
master = true
pythonpath = /path/to/peeringdb-mirror
module = peeringdb_mirror.wsgi:application
buffer-size = 8192
die-on-term = true
workers = 3
threads = 4
```
Save this as `peeringdb.ini`. You can install `uwsgi` in the virtualenv by doing
`pip install uwsgi` and run it with the following `systemd` unit:
```ini
[Unit]
Description=PeeringDB mirror
[Service]
Type=simple
ExecStart=/path/to/peeringdb-mirror/venv/bin/uwsgi /path/to/peeringdb.ini
[Install]
WantedBy=multi-user.target
```