From 4f4d2da551e50f6ae315a9fe71c861a0424d8030 Mon Sep 17 00:00:00 2001 From: Midgard Date: Sat, 25 Jul 2020 10:44:18 +0200 Subject: [PATCH] Did somebody say "Makefile"? --- Makefile | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) 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