diff --git a/fly.toml b/fly.toml
index 0d7b262..773ffe2 100644
--- a/fly.toml
+++ b/fly.toml
@@ -16,6 +16,13 @@ primary_region = "sea"
min_machines_running = 0
processes = ["app"]
+[[http_service.checks]]
+ grace_period = "5s"
+ interval = "30s"
+ method = "GET"
+ timeout = "5s"
+ path = "/"
+
[[vm]]
cpu_kind = "shared"
cpus = 1
diff --git a/go_ji/__init__.py b/go_ji/__init__.py
index 5979752..eaf2d57 100644
--- a/go_ji/__init__.py
+++ b/go_ji/__init__.py
@@ -46,11 +46,15 @@ def create_app(config_override: dict[str, Any] = {}) -> Flask:
profiles_sample_rate=1.0,
)
- # set up db
+ # Should this go on `g`?
db_session = create_db_session(app.config["DB_URL"])
@app.before_request
def require_user() -> None:
+ # Allow anonymous requests for the healthcheck
+ if request.path == "/up":
+ return
+
# I think this is unnecessary, but it also doesn't hurt
if "user" in g:
# Might need to set the sentry user here, we'll see?
@@ -77,6 +81,10 @@ def create_app(config_override: dict[str, Any] = {}) -> Flask:
def shutdown_session(exception=None) -> None: # noqa: ANN001
db_session.remove()
+ @app.route("/up")
+ def up() -> str:
+ return ""
+
@app.route("/")
def index() -> str:
top_shorts = db_session.scalars(
diff --git a/tests/test_go_ji.py b/tests/test_go_ji.py
index 800e016..8715fad 100644
--- a/tests/test_go_ji.py
+++ b/tests/test_go_ji.py
@@ -5,6 +5,12 @@ from sqlalchemy import select
from go_ji.db import Short, User
+def test_up(client):
+ response = client.get("/up")
+
+ assert response.status_code == 200
+
+
class TestAuth:
def test_authenticates(self, app):
with app.test_request_context(