- Setup
- Celery
- Database
- Important notes on dependencies (If project isn't working)
Install all of the requirements.
pip install -r requirements.txt
Install redis and rabbitmq. There are used by celery.
See section Important Notes on Dependencies if there are problems with setup
Celery is used for periodic tasks. As of writing this (Jan 12th 2019) it is used for aborting all matches that went past their max_match_length. This is so players will have their money returned to them if an error occurs in a match and the game does not abort.Start celery:
celery -A djangop worker --loglevel=info -P gevent
Start celery beat:
celery -A djangop beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
Celery also requires redis to be running, open ubuntu and run
service redis-server start
If the database has to be recreated and your getting a no such table error. Try the command:
python manage.py migrate --run-syncdb
# This example uses WebSocket consumer, which is synchronous, and so
# needs the async channel layer functions to be converted.
from asgiref.sync import async_to_sync
class ChatConsumer(WebsocketConsumer):
def connect(self):
async_to_sync(self.channel_layer.group_add)("chat", self.channel_name)
def disconnect(self, close_code):
async_to_sync(self.channel_layer.group_discard)("chat", self.channel_name)