fix(website): fix java restart log (#14471)

This commit is contained in:
Yuki Guo
2026-11-20 16:28:40 +08:00
committed by GitHub
parent fe2ca20895
commit dbd4451bfc
17 changed files with 103 additions and 7 deletions
+2
View File
@@ -885,6 +885,8 @@ func writeContainerLogMessage(w io.Writer, done <-chan struct{}, messages <-chan
return false
}
_, _ = fmt.Fprintf(w, "event: error\ndata: %v\n\n", err)
} else {
_, _ = fmt.Fprint(w, "event: complete\ndata: {}\n\n")
}
return false
}
+14
View File
@@ -213,6 +213,18 @@ func runComposeCmdWithLog(operate string, composePath string, logPath string) er
return nil
}
func updateRuntimeContainerError(cli docker.Client, containerID string, runtime *model.Runtime) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
message, err := cli.ContainerStateError(ctx, containerID)
if err != nil {
global.LOG.Warnf("Failed to inspect runtime container %s: %v", containerID, err)
return
}
// Clear the old summary when the engine has no error; the UI provides guidance.
runtime.Message = message
}
func SyncRuntimesStatus(runtimes []model.Runtime) error {
cli, err := docker.NewClient()
if err != nil {
@@ -238,6 +250,7 @@ func SyncRuntimesStatus(runtimes []model.Runtime) error {
switch contain.State {
case "exited":
runtimes[index].Status = constant.StatusError
updateRuntimeContainerError(cli, contain.ID, &runtimes[index])
case "running":
runtimes[index].Status = constant.StatusRunning
case "paused":
@@ -285,6 +298,7 @@ func SyncRuntimeContainerStatus(runtime *model.Runtime) error {
switch container.State {
case "exited":
runtime.Status = constant.StatusError
updateRuntimeContainerError(cli, container.ID, runtime)
case "running":
runtime.Status = constant.StatusRunning
case "paused":
+12
View File
@@ -78,6 +78,18 @@ func (c Client) Close() {
_ = c.cli.Close()
}
// ContainerStateError may be empty when the application itself exits unsuccessfully.
func (c Client) ContainerStateError(ctx context.Context, containerID string) (string, error) {
info, err := c.cli.ContainerInspect(ctx, containerID)
if err != nil {
return "", err
}
if info.ContainerJSONBase == nil || info.State == nil {
return "", nil
}
return info.State.Error, nil
}
func (c Client) ListContainersByName(names []string) ([]container.Summary, error) {
var (
options container.ListOptions
@@ -1,10 +1,10 @@
<template>
<div v-if="showControl" class="log-toolbar">
<el-select @change="searchLogs" class="fetchClass" v-model="logSearch.mode">
<el-select @change="searchLogs()" class="fetchClass" v-model="logSearch.mode">
<template #prefix>{{ $t('container.fetch') }}</template>
<el-option v-for="item in timeOptions" :key="item.label" :value="item.value" :label="item.label" />
</el-select>
<el-select @change="searchLogs" class="tailClass" v-model.number="logSearch.tail">
<el-select @change="searchLogs()" class="tailClass" v-model.number="logSearch.tail">
<template #prefix>{{ $t('container.lines') }}</template>
<el-option :value="0" :label="$t('commons.table.all')" />
<el-option :value="100" :label="100" />
@@ -13,12 +13,12 @@
<el-option :value="1000" :label="1000" />
</el-select>
<div class="margin-button float-left">
<el-checkbox border @change="searchLogs" v-model="logSearch.isWatch">
<el-checkbox border @change="searchLogs()" v-model="logSearch.isWatch">
{{ $t('commons.button.watch') }}
</el-checkbox>
</div>
<div class="margin-button float-left">
<el-checkbox border @change="searchLogs" v-model="logSearch.isShowTimestamp">
<el-checkbox border @change="searchLogs()" v-model="logSearch.isShowTimestamp">
{{ $t('commons.table.date') }}
</el-checkbox>
</div>
@@ -29,6 +29,12 @@
{{ $t('commons.button.clean') }}
</el-button>
</div>
<el-alert v-if="disconnected" type="warning" :closable="false" show-icon class="mt-2">
<template #title>{{ $t('container.logDisconnected') }}</template>
<el-button size="small" :loading="connecting" @click="searchLogs(true)">
{{ $t('commons.button.reconnect') }}
</el-button>
</el-alert>
<div class="log-container" :style="styleVars">
<div class="xterm-log-viewer" ref="terminalElement"></div>
</div>
@@ -128,6 +134,8 @@ const styleVars = computed(() => ({
const terminalElement = ref<HTMLDivElement | null>(null);
let eventSource: EventSource | null = null;
let searchVersion = 0;
const disconnected = ref(false);
const connecting = ref(false);
let term: Terminal | null = null;
const fitAddon = new FitAddon();
const MAX_VIEW_LINES = 20000;
@@ -170,6 +178,7 @@ const timeOptions = ref([
const stopListening = () => {
searchVersion++;
connecting.value = false;
if (eventSource) {
eventSource.close();
eventSource = null;
@@ -231,14 +240,18 @@ const initTerminal = () => {
});
};
const searchLogs = async () => {
const searchLogs = async (preserveLogs = false) => {
if (Number(logSearch.tail) < 0) {
MsgError(i18n.global.t('container.linesHelper'));
return;
}
stopListening();
const version = searchVersion;
clearTerminal();
if (!preserveLogs) {
clearTerminal();
disconnected.value = false;
}
connecting.value = true;
let currentNode = globalCurrentNode.value;
if (props.node && props.node !== '') {
@@ -253,11 +266,23 @@ const searchLogs = async () => {
const authError = await checkStreamAuth(url, currentNode);
if (version !== searchVersion) return;
if (authError) {
connecting.value = false;
disconnected.value = true;
showEventSourceAuthError(authError);
return;
}
const source = new EventSource(url);
eventSource = source;
source.onopen = () => {
if (version !== searchVersion) return;
connecting.value = false;
disconnected.value = false;
};
source.addEventListener('complete', () => {
if (version !== searchVersion) return;
stopListening();
disconnected.value = logSearch.isWatch;
});
source.addEventListener('container-missing', () => {
if (version !== searchVersion) return;
stopListening();
@@ -272,6 +297,7 @@ const searchLogs = async () => {
source.onerror = (event: MessageEvent) => {
if (version !== searchVersion) return;
stopListening();
disconnected.value = true;
if (event.data && event.data != '') {
MsgError(event.data);
}
+2
View File
@@ -2566,6 +2566,7 @@ const message = {
missing: 'Missing',
},
container: {
logDisconnected: 'The log stream has disconnected. Reconnect to load recent logs and resume streaming.',
logsUnavailable:
'The container does not exist or has been deleted. Container logs are unavailable. Recreate the container and try again.',
nvidiaSupport: 'NVIDIA GPU support',
@@ -5458,6 +5459,7 @@ const message = {
editRuleConfirm: 'Are you sure you want to modify this rule?',
},
runtime: {
statusMessageUnavailable: 'No detailed status information is available. Check the runtime logs for details.',
importEnv: 'Import Environment Variables',
envImportError: 'Line {0}: {1}',
envInvalidAssignment: 'Expected a valid NAME=value assignment',
+4
View File
@@ -2601,6 +2601,8 @@ const message = {
missing: 'No existe',
},
container: {
logDisconnected:
'El flujo de registros se ha desconectado. Vuelve a conectarte para cargar los registros recientes y reanudar la transmisión.',
logsUnavailable:
'El contenedor no existe o se ha eliminado. Los registros del contenedor no están disponibles. Vuelva a crear el contenedor e inténtelo de nuevo.',
nvidiaSupport: 'Compatibilidad con GPU NVIDIA',
@@ -5541,6 +5543,8 @@ const message = {
editRuleConfirm: '¿Confirma que desea modificar esta regla?',
},
runtime: {
statusMessageUnavailable:
'No hay información detallada sobre el estado. Consulta los registros del entorno de ejecución para obtener más detalles.',
importEnv: 'Importar variables de entorno',
envImportError: 'Línea {0}: {1}',
envInvalidAssignment: 'Se esperaba una asignación NOMBRE=valor válida',
+4
View File
@@ -2543,6 +2543,8 @@ const message = {
missing: 'ناموجود',
},
container: {
logDisconnected:
'جریان گزارش قطع شده است. برای بارگیری گزارش‌های اخیر و ادامه دریافت گزارش‌ها، دوباره متصل شوید.',
logsUnavailable:
'کانتینر وجود ندارد یا حذف شده است. لاگ‌های کانتینر در دسترس نیستند. کانتینر را دوباره ایجاد کنید و مجدداً تلاش کنید.',
nvidiaSupport: 'پشتیبانی از GPU انویدیا',
@@ -5414,6 +5416,8 @@ const message = {
editRuleConfirm: 'آیا از تغییر این قانون مطمئن هستید؟',
},
runtime: {
statusMessageUnavailable:
'اطلاعات دقیقی درباره وضعیت در دسترس نیست. برای جزئیات، گزارش‌های محیط اجرا را بررسی کنید.',
importEnv: 'وارد کردن متغیرهای محیطی',
envImportError: 'خط {0}: {1}',
envInvalidAssignment: 'یک عبارت معتبر NAME=value لازم است',
+3
View File
@@ -2549,6 +2549,8 @@ const message = {
missing: '存在しない',
},
container: {
logDisconnected:
'ログストリームが切断されました。再接続して最近のログを読み込み、リアルタイムのログ受信を再開してください。',
logsUnavailable:
'コンテナが存在しないか、削除されています。コンテナのログは表示できません。コンテナを再作成してから、もう一度お試しください。',
nvidiaSupport: 'NVIDIA GPU サポート',
@@ -5435,6 +5437,7 @@ const message = {
editRuleConfirm: 'このルールを変更してもよろしいですか?',
},
runtime: {
statusMessageUnavailable: '詳細なステータス情報はありません。実行環境のログで詳細を確認してください。',
importEnv: '環境変数をインポート',
envImportError: '{0} 行目:{1}',
envInvalidAssignment: '有効な NAME=value 形式で入力してください',
+3
View File
@@ -2519,6 +2519,8 @@ const message = {
missing: '없음',
},
container: {
logDisconnected:
'로그 스트림 연결이 끊어졌습니다. 다시 연결하여 최근 로그를 불러오고 실시간 로그 수신을 재개하세요.',
logsUnavailable:
'컨테이너가 존재하지 않거나 삭제되었습니다. 컨테이너 로그를 확인할 수 없습니다. 컨테이너를 다시 생성한 후 재시도하세요.',
nvidiaSupport: 'NVIDIA GPU 지원',
@@ -5337,6 +5339,7 @@ const message = {
editRuleConfirm: '이 규칙을 수정하시겠습니까?',
},
runtime: {
statusMessageUnavailable: '자세한 상태 정보가 없습니다. 실행 환경 로그에서 자세한 내용을 확인하세요.',
importEnv: '환경 변수 가져오기',
envImportError: '{0}행: {1}',
envInvalidAssignment: '유효한 NAME=value 형식이 필요합니다',
+4
View File
@@ -2492,6 +2492,8 @@ const message = {
missing: 'ບໍ່ມີ',
},
container: {
logDisconnected:
'ການເຊື່ອມຕໍ່ສະຕຣີມບັນທຶກຖືກຕັດ. ກະລຸນາເຊື່ອມຕໍ່ໃໝ່ເພື່ອໂຫຼດບັນທຶກຫຼ້າສຸດ ແລະ ຮັບບັນທຶກແບບເວລາຈິງຕໍ່.',
logsUnavailable:
'ຄອນເທນເນີບໍ່ມີຢູ່ ຫຼື ຖືກລຶບແລ້ວ. ບໍ່ສາມາດເບິ່ງບັນທຶກຂອງຄອນເທນເນີໄດ້. ກະລຸນາສ້າງຄອນເທນເນີໃໝ່ ແລ້ວລອງອີກຄັ້ງ.',
nvidiaSupport: 'ຮອງຮັບ NVIDIA GPU',
@@ -5281,6 +5283,8 @@ const message = {
editRuleConfirm: 'ທ່ານແນ່ໃຈບໍວ່າຕ້ອງການແກ້ໄຂກົດນີ້?',
},
runtime: {
statusMessageUnavailable:
'ບໍ່ມີຂໍ້ມູນສະຖານະແບບລະອຽດ. ກະລຸນາກວດເບິ່ງບັນທຶກຂອງສະພາບແວດລ້ອມການເຮັດວຽກເພື່ອເບິ່ງລາຍລະອຽດ.',
importEnv: 'ນຳເຂົ້າຕົວແປສະພາບແວດລ້ອມ',
envImportError: 'ແຖວ {0}: {1}',
envInvalidAssignment: 'ຕ້ອງເປັນຮູບແບບ NAME=value ທີ່ຖືກຕ້ອງ',
+4
View File
@@ -2593,6 +2593,8 @@ const message = {
missing: 'Tiada',
},
container: {
logDisconnected:
'Sambungan strim log telah terputus. Sambung semula untuk memuatkan log terkini dan meneruskan penstriman.',
logsUnavailable:
'Kontena tidak wujud atau telah dipadamkan. Log kontena tidak tersedia. Cipta semula kontena dan cuba lagi.',
nvidiaSupport: 'Sokongan GPU NVIDIA',
@@ -5539,6 +5541,8 @@ const message = {
editRuleConfirm: 'Adakah anda pasti mahu mengubah peraturan ini?',
},
runtime: {
statusMessageUnavailable:
'Maklumat status terperinci tidak tersedia. Semak log persekitaran masa jalan untuk butiran lanjut.',
importEnv: 'Import Pemboleh Ubah Persekitaran',
envImportError: 'Baris {0}: {1}',
envInvalidAssignment: 'Penetapan NAME=value yang sah diperlukan',
+4
View File
@@ -2601,6 +2601,8 @@ const message = {
missing: 'Não existe',
},
container: {
logDisconnected:
'O fluxo de logs foi desconectado. Reconecte para carregar os logs recentes e retomar a transmissão.',
logsUnavailable:
'O contêiner não existe ou foi excluído. Os logs do contêiner não estão disponíveis. Recrie o contêiner e tente novamente.',
nvidiaSupport: 'Suporte a GPU NVIDIA',
@@ -5572,6 +5574,8 @@ const message = {
editRuleConfirm: 'Tem certeza de que deseja modificar esta regra?',
},
runtime: {
statusMessageUnavailable:
'Não há informações detalhadas sobre o status. Consulte os logs do ambiente de execução para obter mais detalhes.',
importEnv: 'Importar variáveis de ambiente',
envImportError: 'Linha {0}: {1}',
envInvalidAssignment: 'Era esperada uma atribuição NOME=valor válida',
+3
View File
@@ -2593,6 +2593,8 @@ const message = {
missing: 'Отсутствует',
},
container: {
logDisconnected:
'Поток журналов отключён. Подключитесь повторно, чтобы загрузить последние записи и возобновить получение журналов.',
logsUnavailable:
'Контейнер не существует или был удалён. Журналы контейнера недоступны. Создайте контейнер заново и повторите попытку.',
nvidiaSupport: 'Поддержка GPU NVIDIA',
@@ -5540,6 +5542,7 @@ const message = {
editRuleConfirm: 'Вы уверены, что хотите изменить это правило?',
},
runtime: {
statusMessageUnavailable: 'Подробная информация о состоянии недоступна. Проверьте журналы среды выполнения.',
importEnv: 'Импорт переменных окружения',
envImportError: 'Строка {0}: {1}',
envInvalidAssignment: 'Ожидается корректное присваивание NAME=value',
+4
View File
@@ -2588,6 +2588,8 @@ const message = {
missing: 'Mevcut değil',
},
container: {
logDisconnected:
'Günlük akışının bağlantısı kesildi. Son günlükleri yüklemek ve akışı sürdürmek için yeniden bağlanın.',
logsUnavailable:
'Konteyner mevcut değil veya silinmiş. Konteyner günlükleri kullanılamıyor. Konteyneri yeniden oluşturup tekrar deneyin.',
nvidiaSupport: 'NVIDIA GPU desteği',
@@ -5547,6 +5549,8 @@ const message = {
editRuleConfirm: 'Bu kuralı değiştirmek istediğinizden emin misiniz?',
},
runtime: {
statusMessageUnavailable:
'Ayrıntılı durum bilgisi mevcut değil. Ayrıntılar için çalışma ortamı günlüklerini kontrol edin.',
importEnv: 'Ortam Değişkenlerini İçe Aktar',
envImportError: 'Satır {0}: {1}',
envInvalidAssignment: 'Geçerli bir NAME=value ataması bekleniyor',
+2
View File
@@ -2396,6 +2396,7 @@ const message = {
missing: '不存在',
},
container: {
logDisconnected: '日誌串流已中斷,請重新連接以載入最近日誌並繼續接收即時日誌。',
logsUnavailable: '容器不存在或已被刪除,暫無可檢視的容器日誌。請重新建立容器後再試。',
nvidiaSupport: 'NVIDIA GPU 支援',
nvidiaHelper: '註冊 NVIDIA 容器執行環境,需先安裝 NVIDIA Container Toolkit。各容器仍需個別分配 GPU。',
@@ -5044,6 +5045,7 @@ const message = {
editRuleConfirm: '是否確認修改此規則?',
},
runtime: {
statusMessageUnavailable: '暫無詳細狀態資訊,請點擊日誌欄的「查看」排查具體原因。',
importEnv: '匯入環境變數',
envImportError: '第 {0} 行:{1}',
envInvalidAssignment: '應為有效的變數名稱=value',
+2
View File
@@ -2403,6 +2403,7 @@ const message = {
missing: '不存在',
},
container: {
logDisconnected: '日志流已断开,请重新连接以加载最近日志并继续接收实时日志。',
logsUnavailable: '容器不存在或已被删除,暂无可查看的容器日志。请重新创建容器后再试。',
nvidiaSupport: 'NVIDIA GPU 支持',
nvidiaHelper: '注册 NVIDIA 容器运行时,需要先安装 NVIDIA Container Toolkit。具体容器仍需单独分配 GPU。',
@@ -5084,6 +5085,7 @@ const message = {
editRuleConfirm: '是否确认修改该规则?',
},
runtime: {
statusMessageUnavailable: '暂无详细状态信息,请点击日志列的“查看”排查具体原因。',
importEnv: '导入环境变量',
envImportError: '第 {0} 行:{1}',
envInvalidAssignment: '应为有效的变量名=value',
@@ -1,5 +1,5 @@
<template>
<el-popover v-if="showMessage" placement="bottom" :width="400" trigger="hover" :content="row.message">
<el-popover v-if="showMessage" placement="bottom" :width="400" trigger="hover" :content="message">
<template #reference>
<Status :key="row.status" :status="row.status" />
</template>
@@ -12,6 +12,7 @@
<script setup>
import { computed } from 'vue';
import i18n from '@/lang';
import Status from '@/components/status/index.vue';
const props = defineProps({
@@ -21,6 +22,8 @@ const props = defineProps({
},
});
const message = computed(() => props.row.message?.trim() || i18n.global.t('runtime.statusMessageUnavailable'));
const showMessage = computed(() => {
return props.row.status === 'Error' || props.row.status === 'SystemRestart';
});