Add OpenClaw, backup automation, health checks, Telegram notifications
Deploy Dashboard / deploy (push) Failing after 1m52s
Deploy Dashboard / deploy (push) Failing after 1m52s
Phase 6: OpenClaw docker-compose (port 3100) with health check Phase 9: Enhanced backup.sh with full DB/config coverage + Telegram alerts Phase 10: Health checks on all compose files, /api/system/notify endpoint
This commit is contained in:
@@ -1 +1,3 @@
|
||||
GITEA_TOKEN=your_gitea_api_token_here
|
||||
TELEGRAM_BOT_TOKEN=
|
||||
TELEGRAM_CHAT_ID=
|
||||
|
||||
@@ -1,11 +1,30 @@
|
||||
import os
|
||||
import shutil
|
||||
import psutil
|
||||
import platform
|
||||
import time
|
||||
import httpx
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
TELEGRAM_BOT_TOKEN = os.environ.get("TELEGRAM_BOT_TOKEN", "")
|
||||
TELEGRAM_CHAT_ID = os.environ.get("TELEGRAM_CHAT_ID", "")
|
||||
|
||||
|
||||
@router.post("/notify")
|
||||
async def send_notification(body: dict):
|
||||
"""Send a Telegram notification. Body: {"message": "text"}"""
|
||||
msg = body.get("message", "")
|
||||
if not msg or not TELEGRAM_BOT_TOKEN or not TELEGRAM_CHAT_ID:
|
||||
return {"ok": False, "error": "missing message or Telegram config"}
|
||||
async with httpx.AsyncClient() as client:
|
||||
r = await client.post(
|
||||
f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage",
|
||||
data={"chat_id": TELEGRAM_CHAT_ID, "text": msg, "parse_mode": "Markdown"},
|
||||
)
|
||||
return {"ok": r.status_code == 200}
|
||||
|
||||
|
||||
@router.get("/stats")
|
||||
def system_stats():
|
||||
|
||||
@@ -32,9 +32,16 @@ services:
|
||||
- VOLUME_ROOT=/volume1
|
||||
- SSH_HOST=host.docker.internal
|
||||
- SSH_USER=zjgump
|
||||
- TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN:-}
|
||||
- TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID:-}
|
||||
volumes:
|
||||
- /volume1:/volume1
|
||||
- ./ssh/dashboard_terminal:/app/ssh/id_ed25519:ro
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:4000/api/system/stats')"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
networks:
|
||||
|
||||
Reference in New Issue
Block a user