kers/Makefile

39 lines
1.2 KiB
Makefile
Raw Normal View History

2020-07-25 10:44:18 +02:00
SQLITE_FILE ?= kers.sqlite3
2020-07-25 10:59:30 +02:00
KERS_SUPERUSER_ZEUSID ?= 1
KERS_SUPERUSER_NAME ?= admin
KERS_SUPERUSER_PASSWORD ?= admin
2020-07-25 10:44:18 +02:00
2020-07-25 10:59:30 +02:00
# Discover virtualenv location
PYTHON ?= $(shell find -mindepth 3 -maxdepth 3 -path "*/bin/python")
2020-07-25 10:44:18 +02:00
ifeq ($(PYTHON),)
2020-07-25 11:04:56 +02:00
$(error No virtualenv found)
2020-07-25 10:44:18 +02:00
endif
VENVBIN := $(dir $(PYTHON))
2020-07-25 10:59:30 +02:00
.PHONY: server celery beat
2020-07-25 10:44:18 +02:00
server:
$(PYTHON) manage.py runserver
2020-07-22 04:02:13 +02:00
celery:
2020-07-25 10:44:18 +02:00
$(VENVBIN)/celery -A KeRS worker -l info
2020-07-22 04:02:13 +02:00
beat:
2020-07-25 10:44:18 +02:00
$(VENVBIN)/celery -A KeRS beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
2020-07-25 10:59:30 +02:00
.PHONY: migrations migrate superuser
migrations:
$(PYTHON) manage.py makemigrations
migrate:
$(PYTHON) manage.py migrate
superuser:
(sleep 1; echo "$(KERS_SUPERUSER_PASSWORD)"; sleep 0.5; echo "$(KERS_SUPERUSER_PASSWORD)"; sleep 1; echo "y") | \
socat - EXEC:'$(PYTHON) manage.py createsuperuser --username $(KERS_SUPERUSER_NAME) --zeus_id $(KERS_SUPERUSER_ZEUSID)',pty,setsid,ctty
.PHONY: rewrite_migrations
2020-07-25 10:44:18 +02:00
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)"
2020-07-25 10:59:30 +02:00
make migrations
make migrate
make superuser