fix: send-reminder cron

This commit is contained in:
2026-07-17 18:21:34 +02:00
parent 0277502e47
commit a66d8f9e8e
4 changed files with 19 additions and 32 deletions
+12 -10
View File
@@ -6,10 +6,13 @@ USER := $(shell id -un)
PORT ?= 8000
SERVICE := osiris
UNIT_FILE := /etc/systemd/system/$(SERVICE).service
REMINDER_SH := $(PROJECT_DIR)/deploy/send-reminders.sh
CRON_SCHED ?= * * * * *
CRON_LOG ?= $(PROJECT_DIR)/reminders.log
MANAGE := $(UV) run python manage.py
# The reminder job as one line: cron's environment is nearly empty, so uv is
# called by absolute path and loads .env (VAPID keys) itself via --env-file.
# --no-sync: don't resolve dependencies (needs network) on a cron tick.
REMINDER_CMD := cd $(PROJECT_DIR) && $(UV) run --no-sync --env-file .env python manage.py send_reminders
.PHONY: help
help: ## Show this help
@@ -88,24 +91,23 @@ service-uninstall: ## Stop and remove the systemd service
# --- cron ------------------------------------------------------------------
# The script path is the marker: it identifies our line without needing a literal
# '#' comment, which make would strip as a comment of its own.
# 'send[-_]reminders' is the marker identifying our line, so reinstalling stays
# idempotent and also cleans up entries from the old wrapper-script era.
.PHONY: cron
cron: ## Install the reminder cron job (every 10 minutes, idempotent)
@chmod +x $(REMINDER_SH)
@( crontab -l 2>/dev/null | grep -vF '$(REMINDER_SH)' ; \
echo "$(CRON_SCHED) $(REMINDER_SH) >> $(CRON_LOG) 2>&1" ) | crontab -
cron: ## Install the reminder cron job (idempotent)
@( crontab -l 2>/dev/null | grep -vE 'send[-_]reminders' ; \
echo "$(CRON_SCHED) $(REMINDER_CMD) >> $(CRON_LOG) 2>&1" ) | crontab -
@echo "Installed:"
@crontab -l | grep -F '$(REMINDER_SH)'
@crontab -l | grep -F 'send_reminders'
.PHONY: cron-remove
cron-remove: ## Remove the reminder cron job
@crontab -l 2>/dev/null | grep -vF '$(REMINDER_SH)' | crontab -
@crontab -l 2>/dev/null | grep -vE 'send[-_]reminders' | crontab -
@echo "Removed."
.PHONY: cron-test
cron-test: ## Run the reminder job once, reporting what it would send
$(REMINDER_SH) --dry-run
@$(REMINDER_CMD) --dry-run
# --- Frontend --------------------------------------------------------------