Installation guide built on Debian 12
Install
apt install postgresql libpq-dev
Login to PSQL
sudo -u postgres psql
Create a new database
CREATE DATABASE peering_manager ENCODING 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' TEMPLATE template0;
Create a new DB user
CREATE USER peering_manager WITH PASSWORD '*************';
Grant all privileges on new DB to new user
GRANT ALL PRIVILEGES ON DATABASE peering_manager TO peering_manager;
If on PSQL v15+, run the following commands in addition to the latter
\connect peering_manager
GRANT CREATE ON SCHEMA public TO peering_manager;
\q
Test the connection
psql -U peering_manager -W -h localhost peering_manager
Install
apt install redis-server
Test that the Redis service is operational. “PONG” should be returned
redis-cli ping
Install dependencies
apt install python3 python3-dev python3-venv python3-pip git
Clone Peering Manager into /opt/peering-manager
, then move into the project directory
git clone https://github.com/peering-manager/peering-manager.git /opt/peering-manager
cd /opt/peering-manager/
Optionally, checkout the version of PM that you want to run. Explicitly select a version from the repo if you don't wish to run the latest version due to bugs/things breaking.
git checkout v1.8.3
Create a new system user/group for PM
groupadd --system peering-manager
useradd --system --gid peering-manager peering-manager
Change the ownership of the PM directory to the new user
chown --recursive peering-manager /opt/peering-manager
Create a new venv in the installation directory
python3 -m venv /opt/peering-manager/venv
Active the environment
source venv/bin/activate
Install app dependencies
pip3 install --upgrade pip
pip3 install -r requirements.txt
Copy the sample config
cp peering_manager/configuration.example.py peering_manager/configuration.py
Modify the config to fit your environment
vim peering_manager/configuration.py
My config looks like this
ALLOWED_HOSTS = ["*"]
SECRET_KEY = "*************************************"
BASE_PATH = ""
TIME_ZONE = "America/Denver"
DATABASE = {
"NAME": "peering_manager", # Database name
"USER": "peering_manager", # PostgreSQL username
"PASSWORD": "***********", # PostgreSQL password
"HOST": "localhost", # Database server
"PORT": "", # Database port (leave blank for default)
}
REDIS = {
"tasks": {
"HOST": "localhost",
"PORT": 6379,
"PASSWORD": "",
"DATABASE": 0,
"SSL": False,
},
"caching": {
"HOST": "localhost",
"PORT": 6379,
"PASSWORD": "",
"DATABASE": 1,
"SSL": False,
},
}
RQ_DEFAULT_TIMEOUT = 3600
LOGIN_REQUIRED = True
Before PM is able to run, the DB schema must be installed
python3 manage.py migrate
Create a Super User to login to PM to start administering the system
python3 manage.py createsuperuser
Tell PM to copy all static files to the app environment
python3 manage.py collectstatic --no-input
Start PM to test the installation. You can navigate to the web interface at this point. Do not run PM like this in production!
python3 manage.py runserver 0.0.0.0:8000 --insecure
Setup Gunicorn as the application server that will serve PM
Append Gunicorn to the local requirements file
echo 'gunicorn' >> local_requirements.txt
Run the dependency install again to install Gunicorn
pip3 install -r local_requirements.txt
In the app root of PM (/opt/peering-manager/), create a new file for the Gunicorn config
vim gunicorn.py
Use the following config
bind = '127.0.0.1:8001'
workers = 5
threads = 3
timeout = 300
max_requests = 5000
max_requests_jitter = 500
user = 'peering-manager'
Manually start Gunicorn to ensure it runs without error
./venv/bin/gunicorn -c /opt/peering-manager/gunicorn.py peering_manager.wsgi
Create a new service file for PM
vim /etc/systemd/system/peering-manager.service
Use the following config
[Unit]
Description=Peering Manager WSGI Service
Documentation=https://peering-manager.readthedocs.io/
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=peering-manager
Group=peering-manager
PIDFile=/var/tmp/peering-manager.pid
WorkingDirectory=/opt/peering-manager
ExecStart=/opt/peering-manager/venv/bin/gunicorn --pid /var/tmp/peering-manager.pid --pythonpath /opt/peering-manager --config /opt/peering-manager/gunicorn.py peering_manager.wsgi
Restart=on-failure
RestartSec=30
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Create another service file for the PM Request Queue Worker
vim /etc/systemd/system/peering-manager-rqworker@.service
Use the following config
[Unit]
Description=Peering Manager Request Queue Worker
Documentation=https://peering-manager.readthedocs.io/
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=peering-manager
Group=peering-manager
WorkingDirectory=/opt/peering-manager
ExecStart=/opt/peering-manager/venv/bin/python3 /opt/peering-manager/manage.py rqworker
Restart=on-failure
RestartSec=30
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Reload systemd
systemctl daemon-reload
Enable and Start both services. (The RQ Worker supports multiple instances. Simply replace the ‘1’ after the @
with the new consecutive number)
systemctl enable --now peering-manager.service
systemctl enable --now peering-manager-rqworker@1
Check the status of both services
systemctl status peering-manager.service peering-manager-rqworker@1.service
Setup a cronjob that runs the housekeeping process as the peering-manager user once a day.
sudo -u peering-manager crontab -e
Run this job
0 0 * * * /opt/peering-manager/venv/bin/python /opt/peering-manager/manage.py housekeeping
The same configuration can be accomplished using a networked, edge proxy. I'll be accessing PM directly (on-net), so I'll setup the proxy on the server itself.
Install Apache
apt install apache2
Enable required mods
a2enmod headers
a2enmod proxy
a2enmod proxy_http
Create a new vhost config file
vim /etc/apache2/sites-available/peering-manager.conf
Use the following config. Modify it as you see fit.
<VirtualHost *:80>
ProxyPreserveHost On
ServerName peering.example.com
Alias /static /opt/peering-manager/static
<Directory /opt/peering-manager/static>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
<Location /static>
ProxyPass !
</Location>
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
ProxyPass / http://127.0.0.1:8001/
ProxyPassReverse / http://127.0.0.1:8001/
</VirtualHost>
Disable the default vhosts
a2dissite 000-default.conf
Enable the PM vhost
a2ensite peering-manager.conf
Restart Apache
systemctl restart apache2