[claude] feat: Add /api/health endpoint for monitoring (#6) #12
10
api/health/index.json
Normal file
10
api/health/index.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"status": "ok",
|
||||
"services": {
|
||||
"api": true,
|
||||
"agent_loop": false,
|
||||
"websocket": false
|
||||
},
|
||||
"uptime": null,
|
||||
"version": "20260322.230710"
|
||||
}
|
||||
@@ -17,14 +17,17 @@ Generates:
|
||||
"""
|
||||
|
||||
import html
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
SITE_URL = "https://alexanderwhitestone.com"
|
||||
BLOG_DIR = Path(__file__).parent.parent / "blog"
|
||||
ROOT_DIR = Path(__file__).parent.parent
|
||||
BLOG_DIR = ROOT_DIR / "blog"
|
||||
POSTS_DIR = BLOG_DIR / "posts"
|
||||
HEALTH_DIR = ROOT_DIR / "api" / "health"
|
||||
|
||||
PAGE_STYLE = """\
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
@@ -291,6 +294,23 @@ def generate_feed(posts):
|
||||
print(f" Generated feed with {len(entries)} entry/entries.")
|
||||
|
||||
|
||||
def generate_health():
|
||||
"""Generate api/health/index.json with build-time metadata."""
|
||||
HEALTH_DIR.mkdir(parents=True, exist_ok=True)
|
||||
health = {
|
||||
"status": "ok",
|
||||
"services": {
|
||||
"api": True,
|
||||
"agent_loop": False,
|
||||
"websocket": False,
|
||||
},
|
||||
"uptime": None,
|
||||
"version": datetime.now(timezone.utc).strftime("%Y%m%d.%H%M%S"),
|
||||
}
|
||||
(HEALTH_DIR / "index.json").write_text(json.dumps(health, indent=2) + "\n")
|
||||
print(" Generated api/health endpoint.")
|
||||
|
||||
|
||||
def main():
|
||||
print("Building The Scrolls...")
|
||||
posts = load_posts()
|
||||
@@ -299,6 +319,7 @@ def main():
|
||||
print(f" Built: {out.relative_to(BLOG_DIR.parent)}")
|
||||
generate_index(posts)
|
||||
generate_feed(posts)
|
||||
generate_health()
|
||||
print("Build complete.")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user