7d6ee0271d
The container healthcheck hit /rss/...?limit=1 (5s timeout): on a cold cache RSS generation exceeds 5s, or a hung TG RPC makes it hang, so docker/autoheal restarts the container mid-download and corrupts temp files. Replace it with /ping, which reflects process/loop liveness (answers instantly, always) plus TG liveness read from the watchdog's last-probe data — issuing ZERO Telegram RPC. - telegram_client: public watchdog_last_ok_age() — seconds since the last successful watchdog probe (None if never). Pure read of the Stage-1 _wd_last_ok_monotonic field; no RPC. - api_server: /ping route (no token, no TG RPC, no SQLite, no fs scan). healthy = connected and (age is None or age < threshold). age is None right after boot => healthy (don't kill before the first probe). connected coerced to bool so the JSON "connected" field is always a bool (pre-start reports false, never null). - config: TG_PING_UNHEALTHY_AFTER knob, default interval*(failures+1)+timeout = 250s (how long until the watchdog itself gives up), env-overridable. - dockercompose.yml: healthcheck -> curl -sf http://127.0.0.1:80/ping, interval 5m, timeout 5s, retries 3, start_period 30s. Old /rss check removed, not left behind. - tests: 10 (healthy/stale/disconnected/fresh-boot/pre-start-null/no-token + the anti-regression zero-TG-RPC spy across all branches + the accessor). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
def setup_logging(level_name: str = "INFO") -> None:
|
|
"""No-op logging setup for tests (mirrors config.setup_logging signature)."""
|
|
return None
|
|
|
|
def get_settings():
|
|
"""
|
|
Mock config for testing without requiring TG_API_ID and TG_API_HASH
|
|
"""
|
|
return {
|
|
"tg_api_id": 12345,
|
|
"tg_api_hash": "test_hash",
|
|
"session_path": "tests/test_data",
|
|
"api_host": "127.0.0.1",
|
|
"api_port": 8080,
|
|
"pyrogram_bridge_url": "http://test.example.com",
|
|
"log_level": "DEBUG",
|
|
"debug": False,
|
|
"token": "test_token",
|
|
"time_based_merge": False,
|
|
"show_bridge_link": False,
|
|
"show_post_flags": True,
|
|
"proxy": None,
|
|
"trusted_proxies": [],
|
|
"tg_rpc_timeout": 60,
|
|
"tg_watchdog_enabled": True,
|
|
"tg_watchdog_interval": 60,
|
|
"tg_watchdog_timeout": 10,
|
|
"tg_watchdog_failures": 3,
|
|
"tg_watchdog_restart_timeout": 90,
|
|
"tg_watchdog_heartbeat_every": 30,
|
|
"tg_disconnect_flap_limit": 3,
|
|
"tg_disconnect_flap_window": 120,
|
|
"tg_ping_unhealthy_after": 250,
|
|
"media_download_timeout_min": 120,
|
|
"media_download_timeout_max": 1800,
|
|
"media_download_min_speed": 256 * 1024,
|
|
"io_thread_pool_size": 32,
|
|
}
|