tasq/supabase/cron_fallback.sh

26 lines
963 B
Bash

#!/bin/bash
# Fallback notification processor — use if pg_cron + pg_net aren't working.
#
# The edge function handles BOTH enqueue and process internally,
# so this single call is all that's needed.
#
# Setup:
# 1. Set environment variables (or replace inline):
# export SUPABASE_URL="https://YOUR_PROJECT.supabase.co"
# export SUPABASE_SERVICE_ROLE_KEY="your-service-role-key"
#
# 2. Add to crontab (runs every minute):
# */1 * * * * /path/to/supabase/cron_fallback.sh >> /var/log/tasq_notifications.log 2>&1
if [ -z "$SUPABASE_URL" ] || [ -z "$SUPABASE_SERVICE_ROLE_KEY" ]; then
echo "$(date -Iseconds) ERROR: SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY must be set"
exit 1
fi
curl -sS -X POST \
"${SUPABASE_URL}/functions/v1/process_scheduled_notifications" \
-H "Authorization: Bearer ${SUPABASE_SERVICE_ROLE_KEY}" \
-H "Content-Type: application/json" \
-d '{}' \
-o /dev/null -w "$(date -Iseconds) status=%{http_code}\n"