removed unnecessary healthcheck handler

This commit is contained in:
Forden 2021-04-17 00:59:21 +03:00
parent ebab1bf882
commit b670de879a
3 changed files with 0 additions and 31 deletions

1
bot.py
View File

@ -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:

View File

@ -1,2 +1 @@
from .health import health_app
from .tg_updates import tg_updates_app

View File

@ -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)])