fix: robust log retrieval with stderr merging and status check
- Merged stdout and stderr in cmd_logs to capture all container output. - Added explicit check for container status when no logs are returned. - Improved feedback for empty logs in running containers. - Fixed "No logs" placeholder when container writes exclusively to stderr.
This commit is contained in:
16
install.sh
16
install.sh
@@ -332,18 +332,18 @@ 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
|
||||
|
||||
running = await proxy_running()
|
||||
if not running:
|
||||
text = "❌ <b>Контейнер не найден или остановлен.</b>"
|
||||
is_running = await proxy_running()
|
||||
if not is_running:
|
||||
text = "❌ <b>Прокси-контейнер не запущен или не найден.</b>"
|
||||
else:
|
||||
# Запрашиваем 50 строк и объединяем выводы
|
||||
# Запрашиваем 50 строк и объединяем выводы (out и err)
|
||||
code, out, err = await sh("docker", "logs", "--tail", "50", CONTAINER_NAME, timeout=15)
|
||||
combined_logs = (out.strip() + "\n" + err.strip()).strip()
|
||||
full_logs = (out.strip() + "\n" + err.strip()).strip()
|
||||
|
||||
if not combined_logs:
|
||||
text = "📋 <b>Контейнер запущен, но логи пока пусты.</b>\n<i>Попробуйте подключиться к прокси, чтобы появились записи.</i>"
|
||||
if not full_logs:
|
||||
text = "📋 <b>Контейнер запущен, но записей в логах пока нет.</b>\n<i>Попробуйте подключиться к прокси, чтобы данные появились.</i>"
|
||||
else:
|
||||
text = f"<pre>{html.escape(combined_logs)}</pre>"
|
||||
text = f"<pre>{html.escape(full_logs)}</pre>"
|
||||
|
||||
kb = InlineKeyboardMarkup([[InlineKeyboardButton("◀️ Меню", callback_data="menu_main")]])
|
||||
if update.callback_query:
|
||||
|
||||
Reference in New Issue
Block a user