-
Notifications
You must be signed in to change notification settings - Fork 10
Project deploy on OpenShift
Oleg Ovcharenko edited this page Feb 22, 2022
·
1 revision
- Create project on openshift:
oc new-project rd2l
- Create ladder app from github source:
oc new-app https://github.com/UncleVasya/Dota2-EU-Ladder --name=ladder
-
If you get Error 137 during build, you need to increase memory limit in buildconfig.
Edit YAML for buildconfig (and deployconfig if first doesn't help):
spec: resources: limits: memory: "1Gi"or use console version:
- buildconfig:
oc.exe patch bc/ladder --patch "{\"spec\":{\"resources\":{\"limits\":{\"memory\":\"1Gi\"}}}}"- deployconfig:
oc.exe patch dc/ladder --patch "{\"spec\":{\"resources\":{\"limits\":{\"memory\":\"1Gi\"}}}}" -
Add persistent storage for database:
oc set volume dc/ladder --add --name=data --claim-name=ladder-data --type pvc --claim-size=1Gi --mount-path /opt/app-root/src/data
- Expose app for web requests:
oc expose svc/ladder
Or create Route in web console manually.
At this point you should be able to visit ladder web interface.
- Create superuser. Open running pod in a terminal and run:
python manage.py createsuperuser
- Add environment vars to DeployConfig:
BOT_LOGIN=euladder_bot
BOT_PASSWORD=****
LOBBY_PASSWORD=****
LEAGUE_ID=****
DISCORD_BOT_TOKEN=****
BASE_URL=https://inhouse.rd2l.eu
Hints for local development on Windows:
- In .virtualenv\Scripts\activate.bat set env variables:
set "BOT_LOGIN=euladder_bot"
set "BOT_PASSWORD=****"
set "LOBBY_PASSWORD=****"
set "LEAGUE_ID=****"
set "DISCORD_BOT_TOKEN=****"
- If wokring from PyCharm, its terminal won't have these variables set by default. You need to deactivate / activate virtualenv manually:
.virtualenv\Scripts\deactivate.bat
.virtualenv\Scripts\activate.bat
Create a session for website:
tmux new -s website
Inside tmux:
1) gunicorn -b 0.0.0.0:8000 dota2_eu_ladder.wsgi:application
2) press Ctrl+B to enter commands mode
3) press 'd' to detach from session
Create a session for dota bot:
tmux new -s dota_bot
Inside tmux:
1) python manage.py dota_bot -n 3
2) press Ctrl+B to enter commands mode
3) press 'd' to detach from session
Then do the same for discord bot:
tmux new -s discord_bot
To connect to exisiting session
tmux a -t dota_bot
oc rsync ladder-63-9c5m5:/opt/app-root/src/data ./_backups