mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-11-20 00:01:06 +00:00
fix(website): fix java restart log
This commit is contained in:
@@ -881,6 +881,8 @@ func writeContainerLogMessage(w io.Writer, done <-chan struct{}, messages <-chan
|
||||
// logs before handling its result, or a ready error channel can drop the tail.
|
||||
if err := <-errors; err != nil {
|
||||
_, _ = fmt.Fprintf(w, "event: error\ndata: %v\n\n", err)
|
||||
} else {
|
||||
_, _ = fmt.Fprint(w, "event: complete\ndata: {}\n\n")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -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":
|
||||
|
||||
@@ -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.onmessage = (event: MessageEvent) => {
|
||||
if (version !== searchVersion) return;
|
||||
term?.write(Base64.toUint8Array(event.data));
|
||||
@@ -265,6 +290,7 @@ const searchLogs = async () => {
|
||||
source.onerror = (event: MessageEvent) => {
|
||||
if (version !== searchVersion) return;
|
||||
stopListening();
|
||||
disconnected.value = true;
|
||||
if (event.data && event.data != '') {
|
||||
MsgError(event.data);
|
||||
}
|
||||
|
||||
@@ -2566,6 +2566,7 @@ const message = {
|
||||
missing: 'Missing',
|
||||
},
|
||||
container: {
|
||||
logDisconnected: 'The log stream has disconnected. Reconnect to load recent logs and resume streaming.',
|
||||
nvidiaSupport: 'NVIDIA GPU support',
|
||||
nvidiaHelper:
|
||||
'Register the NVIDIA container runtime. Install NVIDIA Container Toolkit first. Assign GPUs to each container separately.',
|
||||
@@ -5447,6 +5448,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',
|
||||
|
||||
@@ -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.',
|
||||
nvidiaSupport: 'Compatibilidad con GPU NVIDIA',
|
||||
nvidiaHelper:
|
||||
'Registra el entorno de ejecución de NVIDIA. Instala primero NVIDIA Container Toolkit. Asigna las GPU a cada contenedor por separado.',
|
||||
@@ -5529,6 +5531,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',
|
||||
|
||||
@@ -2543,6 +2543,8 @@ const message = {
|
||||
missing: 'ناموجود',
|
||||
},
|
||||
container: {
|
||||
logDisconnected:
|
||||
'جریان گزارش قطع شده است. برای بارگیری گزارشهای اخیر و ادامه دریافت گزارشها، دوباره متصل شوید.',
|
||||
nvidiaSupport: 'پشتیبانی از GPU انویدیا',
|
||||
nvidiaHelper:
|
||||
'محیط اجرای کانتینر NVIDIA را ثبت میکند. ابتدا NVIDIA Container Toolkit را نصب کنید. GPU را جداگانه به هر کانتینر اختصاص دهید.',
|
||||
@@ -5403,6 +5405,8 @@ const message = {
|
||||
editRuleConfirm: 'آیا از تغییر این قانون مطمئن هستید؟',
|
||||
},
|
||||
runtime: {
|
||||
statusMessageUnavailable:
|
||||
'اطلاعات دقیقی درباره وضعیت در دسترس نیست. برای جزئیات، گزارشهای محیط اجرا را بررسی کنید.',
|
||||
importEnv: 'وارد کردن متغیرهای محیطی',
|
||||
envImportError: 'خط {0}: {1}',
|
||||
envInvalidAssignment: 'یک عبارت معتبر NAME=value لازم است',
|
||||
|
||||
@@ -2549,6 +2549,8 @@ const message = {
|
||||
missing: '存在しない',
|
||||
},
|
||||
container: {
|
||||
logDisconnected:
|
||||
'ログストリームが切断されました。再接続して最近のログを読み込み、リアルタイムのログ受信を再開してください。',
|
||||
nvidiaSupport: 'NVIDIA GPU サポート',
|
||||
nvidiaHelper:
|
||||
'NVIDIA コンテナーランタイムを登録します。先に NVIDIA Container Toolkit をインストールしてください。GPU はコンテナーごとに割り当てる必要があります。',
|
||||
@@ -5425,6 +5427,7 @@ const message = {
|
||||
editRuleConfirm: 'このルールを変更してもよろしいですか?',
|
||||
},
|
||||
runtime: {
|
||||
statusMessageUnavailable: '詳細なステータス情報はありません。実行環境のログで詳細を確認してください。',
|
||||
importEnv: '環境変数をインポート',
|
||||
envImportError: '{0} 行目:{1}',
|
||||
envInvalidAssignment: '有効な NAME=value 形式で入力してください',
|
||||
|
||||
@@ -2519,6 +2519,8 @@ const message = {
|
||||
missing: '없음',
|
||||
},
|
||||
container: {
|
||||
logDisconnected:
|
||||
'로그 스트림 연결이 끊어졌습니다. 다시 연결하여 최근 로그를 불러오고 실시간 로그 수신을 재개하세요.',
|
||||
nvidiaSupport: 'NVIDIA GPU 지원',
|
||||
nvidiaHelper:
|
||||
'NVIDIA 컨테이너 런타임을 등록합니다. 먼저 NVIDIA Container Toolkit을 설치하세요. GPU는 각 컨테이너에 별도로 할당해야 합니다.',
|
||||
@@ -5327,6 +5329,7 @@ const message = {
|
||||
editRuleConfirm: '이 규칙을 수정하시겠습니까?',
|
||||
},
|
||||
runtime: {
|
||||
statusMessageUnavailable: '자세한 상태 정보가 없습니다. 실행 환경 로그에서 자세한 내용을 확인하세요.',
|
||||
importEnv: '환경 변수 가져오기',
|
||||
envImportError: '{0}행: {1}',
|
||||
envInvalidAssignment: '유효한 NAME=value 형식이 필요합니다',
|
||||
|
||||
@@ -2492,6 +2492,8 @@ const message = {
|
||||
missing: 'ບໍ່ມີ',
|
||||
},
|
||||
container: {
|
||||
logDisconnected:
|
||||
'ການເຊື່ອມຕໍ່ສະຕຣີມບັນທຶກຖືກຕັດ. ກະລຸນາເຊື່ອມຕໍ່ໃໝ່ເພື່ອໂຫຼດບັນທຶກຫຼ້າສຸດ ແລະ ຮັບບັນທຶກແບບເວລາຈິງຕໍ່.',
|
||||
nvidiaSupport: 'ຮອງຮັບ NVIDIA GPU',
|
||||
nvidiaHelper:
|
||||
'ລົງທະບຽນ NVIDIA runtime ສຳລັບຄອນເທນເນີ. ຕິດຕັ້ງ NVIDIA Container Toolkit ກ່ອນ ແລະ ຈັດສັນ GPU ໃຫ້ແຕ່ລະຄອນເທນເນີແຍກກັນ.',
|
||||
@@ -5271,6 +5273,8 @@ const message = {
|
||||
editRuleConfirm: 'ທ່ານແນ່ໃຈບໍວ່າຕ້ອງການແກ້ໄຂກົດນີ້?',
|
||||
},
|
||||
runtime: {
|
||||
statusMessageUnavailable:
|
||||
'ບໍ່ມີຂໍ້ມູນສະຖານະແບບລະອຽດ. ກະລຸນາກວດເບິ່ງບັນທຶກຂອງສະພາບແວດລ້ອມການເຮັດວຽກເພື່ອເບິ່ງລາຍລະອຽດ.',
|
||||
importEnv: 'ນຳເຂົ້າຕົວແປສະພາບແວດລ້ອມ',
|
||||
envImportError: 'ແຖວ {0}: {1}',
|
||||
envInvalidAssignment: 'ຕ້ອງເປັນຮູບແບບ NAME=value ທີ່ຖືກຕ້ອງ',
|
||||
|
||||
@@ -2593,6 +2593,8 @@ const message = {
|
||||
missing: 'Tiada',
|
||||
},
|
||||
container: {
|
||||
logDisconnected:
|
||||
'Sambungan strim log telah terputus. Sambung semula untuk memuatkan log terkini dan meneruskan penstriman.',
|
||||
nvidiaSupport: 'Sokongan GPU NVIDIA',
|
||||
nvidiaHelper:
|
||||
'Daftarkan runtime kontena NVIDIA. Pasang NVIDIA Container Toolkit dahulu. Peruntukkan GPU kepada setiap kontena secara berasingan.',
|
||||
@@ -5527,6 +5529,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',
|
||||
|
||||
@@ -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.',
|
||||
nvidiaSupport: 'Suporte a GPU NVIDIA',
|
||||
nvidiaHelper:
|
||||
'Registra o runtime de contêiner NVIDIA. Instale primeiro o NVIDIA Container Toolkit. Atribua GPUs a cada contêiner separadamente.',
|
||||
@@ -5561,6 +5563,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',
|
||||
|
||||
@@ -2593,6 +2593,8 @@ const message = {
|
||||
missing: 'Отсутствует',
|
||||
},
|
||||
container: {
|
||||
logDisconnected:
|
||||
'Поток журналов отключён. Подключитесь повторно, чтобы загрузить последние записи и возобновить получение журналов.',
|
||||
nvidiaSupport: 'Поддержка GPU NVIDIA',
|
||||
nvidiaHelper:
|
||||
'Регистрирует среду выполнения контейнеров NVIDIA. Сначала установите NVIDIA Container Toolkit. Назначайте GPU каждому контейнеру отдельно.',
|
||||
@@ -5528,6 +5530,7 @@ const message = {
|
||||
editRuleConfirm: 'Вы уверены, что хотите изменить это правило?',
|
||||
},
|
||||
runtime: {
|
||||
statusMessageUnavailable: 'Подробная информация о состоянии недоступна. Проверьте журналы среды выполнения.',
|
||||
importEnv: 'Импорт переменных окружения',
|
||||
envImportError: 'Строка {0}: {1}',
|
||||
envInvalidAssignment: 'Ожидается корректное присваивание NAME=value',
|
||||
|
||||
@@ -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.',
|
||||
nvidiaSupport: 'NVIDIA GPU desteği',
|
||||
nvidiaHelper:
|
||||
'NVIDIA konteyner çalışma zamanını kaydeder. Önce NVIDIA Container Toolkit kurun. GPU’ları her konteynere ayrı ayrı atayın.',
|
||||
@@ -5536,6 +5538,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',
|
||||
|
||||
@@ -2396,6 +2396,7 @@ const message = {
|
||||
missing: '不存在',
|
||||
},
|
||||
container: {
|
||||
logDisconnected: '日誌串流已中斷,請重新連接以載入最近日誌並繼續接收即時日誌。',
|
||||
nvidiaSupport: 'NVIDIA GPU 支援',
|
||||
nvidiaHelper: '註冊 NVIDIA 容器執行環境,需先安裝 NVIDIA Container Toolkit。各容器仍需個別分配 GPU。',
|
||||
nvidiaLocalOnly: '僅支援本機預設 Docker Socket。',
|
||||
@@ -5036,6 +5037,7 @@ const message = {
|
||||
editRuleConfirm: '是否確認修改此規則?',
|
||||
},
|
||||
runtime: {
|
||||
statusMessageUnavailable: '暫無詳細狀態資訊,請點擊日誌欄的「查看」排查具體原因。',
|
||||
importEnv: '匯入環境變數',
|
||||
envImportError: '第 {0} 行:{1}',
|
||||
envInvalidAssignment: '應為有效的變數名稱=value',
|
||||
|
||||
@@ -2403,6 +2403,7 @@ const message = {
|
||||
missing: '不存在',
|
||||
},
|
||||
container: {
|
||||
logDisconnected: '日志流已断开,请重新连接以加载最近日志并继续接收实时日志。',
|
||||
nvidiaSupport: 'NVIDIA GPU 支持',
|
||||
nvidiaHelper: '注册 NVIDIA 容器运行时,需要先安装 NVIDIA Container Toolkit。具体容器仍需单独分配 GPU。',
|
||||
nvidiaLocalOnly: '仅支持本机默认 Docker Socket。',
|
||||
@@ -5076,6 +5077,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';
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user