iggyfisk / highperch

highper.ch official web
2 stars 1 forks source link

highper.ch web

Replay database extraordinarie

Dev environment

Tested editors

VSCode

Symbols, highlighting, formatting, debugging

Pycharm

Symbols, highlighting, formatting, debugging. Just open the project and select your virtual environment as the interpreter when prompted

Atom

Highlighting. I'm sure the rest can be configured if you install enough plugins.

Replay data

Look at test/Reforged1Pretty.json and test/Reforged2Pretty.json for a human readable glance of the parsed format.

CSS

Since we're writing styles in SCSS, whenever changes are made we'll need to compile the SCSS to plain CSS. pip install libsass gives you the library you need to run build.py in /perchweb/static/scss/.

Production deployment

Some updates will change the formats of the SQLite .dbs and/or replaydata/.jsons, manual update script will be provided.

Production environment

This goes in a systemd unit, e.g. /etc/systemd/system/highperch.service:

[Unit]
Description=Gunicorn WSGI for the Highperch Flask app
After=network.target

[Service]
User=www-data
Group=www-data
WorkingDirectory=/var/www/highper.ch/perchweb
Environment="PATH=/var/www/highper.ch/env/bin://usr/bin/"
EnvironmentFile=/etc/nginx/highperch-envvars
ExecStart=/var/www/highper.ch/env/bin/gunicorn --workers 4 --log-file /var/log/nginx/gunicorn/highperch.log --log-level DEBUG --bind unix:../highperch.sock app:app

[Install]
WantedBy=multi-user.target

The EnvironmentFile from the unit above needs to contain these lines:

SERVER_HOST=localhost
SERVER_PORT=5000
HIGHPERCH_ENVIRONMENT=production
HIGHPERCH_FLASK_KEY=(it's a secret)
HIGHPERCH_ADMIN_HASH=(it's a secret)

The stream poller gets called with this cron job, run as www-data:

*/1 * * * * /usr/bin/env bash -c 'source /etc/nginx/streampoll-envvars && source /var/www/highper.ch/env/bin/activate && python /var/www/highper.ch/streampoller.py'

The envvar file from the above needs to contain these lines:

export HIGHPERCH_STREAM_WEBHOOK=(it's a secret)
export HIGHPERCH_TWITCH_CLIENT_ID=(it's a secret)