summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryyamashita <yyamashita@hetzner.yyamashita.com>2026-10-31 19:31:13 +0900
committeryyamashita <yyamashita@hetzner.yyamashita.com>2026-10-31 19:31:13 +0900
commit5029f44f4707051e0da39d5cfdae9f9eded12ef3 (patch)
treed176b42a42fd16b2b3dd4296de38164969b3ba07
parent4d9c72a724b46c8b9204cbc8d3d710de769b72ba (diff)
status: add ntfy app deep link to status page
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-rw-r--r--CLAUDE.md1
-rw-r--r--status/app.py7
2 files changed, 7 insertions, 1 deletions
diff --git a/CLAUDE.md b/CLAUDE.md
index 6861c6a..8d539d2 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -142,6 +142,7 @@ ssh root@localhost 'bash /app/infra/ntfy/deploy.sh && bash /app/infra/status/dep
ssh -t root@localhost 'bash /app/infra/ntfy/install.sh' # 管理ユーザー作成(パスワード入力)
# → トークンを発行して status/.env に NTFY_URL / NTFY_TOKEN を書き込み、status-app を再起動
# スマホ: ntfy アプリでサーバー https://ntfy.yyamashita.com を追加し、トピック status を購読(admin でログイン)
+# ディープリンク: ntfy://ntfy.yyamashita.com/status(status ページ下部にもリンクあり)
# ntfy テスト送信
ssh root@localhost 'docker exec ntfy ntfy publish --token "$(grep NTFY_TOKEN /app/infra/status/.env | cut -d= -f2)" http://localhost/status "test"'
diff --git a/status/app.py b/status/app.py
index 7326b01..9a20c04 100644
--- a/status/app.py
+++ b/status/app.py
@@ -22,6 +22,8 @@ NTFY_URL = os.environ.get("NTFY_URL", "") # 例: http://ntfy/status(空なら
NTFY_TOKEN = os.environ.get("NTFY_TOKEN", "")
FAIL_THRESHOLD = int(os.environ.get("FAIL_THRESHOLD", "2")) # 連続失敗この回数で DOWN 通知
PUBLIC_URL = os.environ.get("PUBLIC_URL", "https://status.yyamashita.com")
+# ntfy アプリで通知トピックを開くディープリンク(空ならページに出さない)
+NTFY_DEEPLINK = os.environ.get("NTFY_DEEPLINK", "ntfy://ntfy.yyamashita.com/status")
# 毎朝のサマリー通知(-1 で無効)。JST は DST がないので固定オフセットで扱う
SUMMARY_HOUR = int(os.environ.get("SUMMARY_HOUR", "8"))
LOCAL_TZ = timezone(timedelta(hours=float(os.environ.get("SUMMARY_TZ_OFFSET", "9"))))
@@ -190,6 +192,9 @@ def render_html(data):
else:
banner = '<div class="banner d">Some systems are down</div>'
checked = data["services"][0]["checked_at"] if data["services"] else "-"
+ subscribe = (
+ f' · <a href="{escape(NTFY_DEEPLINK)}">Subscribe in ntfy app</a>' if NTFY_DEEPLINK else ""
+ )
return f"""<!DOCTYPE html>
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="refresh" content="{INTERVAL}"><title>Status - yyamashita.com</title>
@@ -206,7 +211,7 @@ small{{color:#888}}
<h2>yyamashita.com status</h2>
{banner}
<table>{"".join(rows)}</table>
-<p><small>Last checked: {checked} (every {INTERVAL}s) · <a href="/api/status">JSON</a></small></p>
+<p><small>Last checked: {checked} (every {INTERVAL}s) · <a href="/api/status">JSON</a>{subscribe}</small></p>
</body></html>"""