From 5da628ed70092445bf4f3b6f9b74c6e04c697579 Mon Sep 17 00:00:00 2001 From: kobaltgit Date: Mon, 6 Apr 2026 13:05:46 +0300 Subject: [PATCH] fix: improve docker logs retrieval and diagnostics - Updated cmd_logs to combine stdout and stderr streams. - Added a check for container existence before fetching logs. - Increased log tail limit to 50 lines. - Improved user feedback when logs are empty but the container is running. --- install.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index eee7c9d..0f63798 100644 --- a/install.sh +++ b/install.sh @@ -331,11 +331,25 @@ async def cmd_restart(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: async def cmd_logs(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: if not update.effective_user or not _ok(update.effective_user.id): return - code, out, err = await sh("docker", "logs", "--tail", "30", CONTAINER_NAME, timeout=15) - text = f"
{html.escape(out or err or 'Логов нет.')}
" + + running = await proxy_running() + if not running: + text = "❌ Контейнер не найден или остановлен." + else: + # Запрашиваем 50 строк и объединяем выводы + code, out, err = await sh("docker", "logs", "--tail", "50", CONTAINER_NAME, timeout=15) + combined_logs = (out.strip() + "\n" + err.strip()).strip() + + if not combined_logs: + text = "📋 Контейнер запущен, но логи пока пусты.\nПопробуйте подключиться к прокси, чтобы появились записи." + else: + text = f"
{html.escape(combined_logs)}
" + kb = InlineKeyboardMarkup([[InlineKeyboardButton("◀️ Меню", callback_data="menu_main")]]) - if update.callback_query: await update.callback_query.edit_message_text(text, parse_mode="HTML", reply_markup=kb) - else: await update.message.reply_text(text, parse_mode="HTML", reply_markup=kb) + if update.callback_query: + await update.callback_query.edit_message_text(text, parse_mode="HTML", reply_markup=kb) + else: + await update.message.reply_text(text, parse_mode="HTML", reply_markup=kb) async def do_install(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: domain = ctx.user_data.get("install_domain", "google.com")