diff --git a/bot.py b/bot.py index 54a9fa8..407db47 100644 --- a/bot.py +++ b/bot.py @@ -35,7 +35,6 @@ async def init() -> web.Application: scheduler = await aiojobs.create_scheduler() app = web.Application() subapps: List[str, web.Application] = [ - ('/health/', web_handlers.health_app), ('/tg/webhooks/', web_handlers.tg_updates_app), ] for prefix, subapp in subapps: diff --git a/web_handlers/__init__.py b/web_handlers/__init__.py index 38f3213..0ea0cf8 100644 --- a/web_handlers/__init__.py +++ b/web_handlers/__init__.py @@ -1,2 +1 @@ -from .health import health_app from .tg_updates import tg_updates_app diff --git a/web_handlers/health.py b/web_handlers/health.py deleted file mode 100644 index aae7791..0000000 --- a/web_handlers/health.py +++ /dev/null @@ -1,29 +0,0 @@ -from typing import Tuple - -from aiogram import Bot -from aiohttp import web -from aiohttp_healthcheck import HealthCheck -from loguru import logger - - -async def health_check() -> Tuple[bool, str]: - return True, 'Server alive' - - -async def check_webhook() -> Tuple[bool, str]: - from data import config - bot: Bot = health_app['bot'] - - webhook = await bot.get_webhook_info() - if webhook.url and webhook.url == config.WEBHOOK_URL: - return True, f'Webhook configured. Pending updates count {webhook.pending_update_count}' - else: - logger.error('Configured wrong webhook URL {webhook}', webhook=webhook.url) - return False, 'Configured invalid webhook URL' - - -health_app = web.Application() -health = HealthCheck() -health.add_check(health_check) -health.add_check(check_webhook) -health_app.add_routes([web.get('/check', health)])