Add restart confirmation from watchdog alerts

This commit is contained in:
2026-02-07 22:45:10 +03:00
parent 23fa70f15c
commit e3a1321d3f
2 changed files with 71 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import asyncio
from datetime import datetime, timezone
from typing import Dict
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from services.runner import run_cmd
@@ -109,6 +110,21 @@ async def docker_watchdog(container_map, notify, bot, chat_id):
state = "error"
state = state.strip()
if last.get(alias) != state:
await notify(bot, chat_id, f"🐳 {alias}: {state}")
if state != "running":
kb = InlineKeyboardMarkup(
inline_keyboard=[[
InlineKeyboardButton(
text="🔄 Restart",
callback_data=f"wdrestart:{alias}"
)
]]
)
await bot.send_message(
chat_id,
f"🐳 {alias}: {state}",
reply_markup=kb,
)
else:
await notify(bot, chat_id, f"🐳 {alias}: {state}")
last[alias] = state
await asyncio.sleep(120)