diff --git a/Makefile b/Makefile index bc5c2ae..d0e4108 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,25 @@ -celery: - celery -A KeRS worker -l info -beat: - celery -A KeRS beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler +SQLITE_FILE ?= kers.sqlite3 + +PYTHON := $(shell find -mindepth 3 -maxdepth 3 -path "*/bin/python") +ifeq ($(PYTHON),) + $(error No virtualenv found) +endif +VENVBIN := $(dir $(PYTHON)) + +.PHONY: server celery beat rewrite_migrations + server: - python manage.py runserver + $(PYTHON) manage.py runserver +celery: + $(VENVBIN)/celery -A KeRS worker -l info +beat: + $(VENVBIN)/celery -A KeRS beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler + +rewrite_migrations: + @printf "Only for when there is no data in production yet. Continue? (y/N) "; read continue; [ "$$continue" = y ] + rm -f events/migrations/0*_*.py users/migrations/0*_*.py + rm -f "$(SQLITE_FILE)" + $(PYTHON) manage.py makemigrations + $(PYTHON) manage.py migrate + (sleep 1; echo "admin"; sleep 0.5; echo "admin"; sleep 1; echo "y") | \ + socat - EXEC:'$(PYTHON) manage.py createsuperuser --username admin --zeus_id 1',pty,setsid,ctty