Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import sentry_sdk
from sentry_sdk.integrations.chalice import ChaliceIntegration

from chalice.app import Chalice
from chalice.app import Chalice, Cron, Rate
from chalicelib.modules.supabase_client import SupabaseClient


# API imports
Expand Down Expand Up @@ -146,3 +147,20 @@ def initialize_app():
@app.route("/")
def index():
return {"hello": "world"}


################################################################
# Cron jobs
################################################################


@app.schedule(Cron("0", "6", "*", "*", "?", "*")) # Daily at 6 AM UTC / 1 AM EST
def supabase_ping(event):
try:
supabase = SupabaseClient.get_client()
res = supabase.rpc("healthcheck").execute() # harmless keep-alive
print("Supabase healthcheck OK:", res.data)
return {"ok": True}
except Exception as e:
print("Ping failed:", e)
raise
7 changes: 7 additions & 0 deletions supabase/migrations/20251122210130_healthcheck.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
create or replace function healthcheck()
returns void
language sql
stable
as $$
select;
$$;