fix: logs for not running containers
This commit is contained in:
parent
d4b7318413
commit
6882e83d1e
@ -1243,7 +1243,10 @@ export async function getApplicationLogs(request: FastifyRequest<GetApplicationL
|
|||||||
return { logs: sortedLogs }
|
return { logs: sortedLogs }
|
||||||
// }
|
// }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const { statusCode } = error;
|
const { statusCode, stderr } = error;
|
||||||
|
if (stderr.startsWith('Error: No such container')) {
|
||||||
|
return { logs: [], noContainer: true }
|
||||||
|
}
|
||||||
if (statusCode === 404) {
|
if (statusCode === 404) {
|
||||||
return {
|
return {
|
||||||
logs: []
|
logs: []
|
||||||
|
@ -160,12 +160,12 @@
|
|||||||
<span>Logs</span>
|
<span>Logs</span>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
class:text-stone-600={$status.application.overallStatus !== 'healthy'}
|
class:text-stone-600={$status.application.overallStatus === 'stopped'}
|
||||||
class="rounded"
|
class="rounded"
|
||||||
class:bg-coollabs={$page.url.pathname === `/applications/${$page.params.id}/logs`}
|
class:bg-coollabs={$page.url.pathname === `/applications/${$page.params.id}/logs`}
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href={$status.application.overallStatus === 'healthy' ? `/applications/${$page.params.id}/logs` : ''}
|
href={$status.application.overallStatus !== 'stopped' ? `/applications/${$page.params.id}/logs` : ''}
|
||||||
class="no-underline w-full"
|
class="no-underline w-full"
|
||||||
><svg
|
><svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
@ -394,10 +394,13 @@
|
|||||||
|
|
||||||
{:else if $isDeploymentEnabled && !$page.url.pathname.startsWith(`/applications/${id}/configuration/`)}
|
{:else if $isDeploymentEnabled && !$page.url.pathname.startsWith(`/applications/${id}/configuration/`)}
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm gap-2 btn-primary"
|
class="btn btn-sm gap-2"
|
||||||
|
class:btn-error={$status.application.overallStatus === 'degraded'}
|
||||||
|
class:btn-primary={$status.application.overallStatus !== 'degraded'}
|
||||||
disabled={!$isDeploymentEnabled}
|
disabled={!$isDeploymentEnabled}
|
||||||
on:click={() => handleDeploySubmit(false)}
|
on:click={() => handleDeploySubmit(false)}
|
||||||
>
|
>
|
||||||
|
{#if $status.application.overallStatus !== 'degraded'}
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="w-6 h-6"
|
class="w-6 h-6"
|
||||||
@ -411,7 +414,26 @@
|
|||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
<path d="M7 4v16l13 -8z" />
|
<path d="M7 4v16l13 -8z" />
|
||||||
</svg>
|
</svg>
|
||||||
{$status.application.overallStatus === 'degraded' ? 'Restart Degraded Services' : 'Deploy'}
|
{:else}
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="w-6 h-6"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
fill="none"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
|
<path
|
||||||
|
d="M16.3 5h.7a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h5l-2.82 -2.82m0 5.64l2.82 -2.82"
|
||||||
|
transform="rotate(-45 12 12)"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
{/if}
|
||||||
|
{$status.application.overallStatus === 'degraded' ? 'Restart Degraded Stack' : 'Deploy'}
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $location && $status.application.overallStatus === 'healthy'}
|
{#if $location && $status.application.overallStatus === 'healthy'}
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
import { errorNotification } from '$lib/common';
|
import { errorNotification } from '$lib/common';
|
||||||
import { onMount, onDestroy } from 'svelte';
|
import { onMount, onDestroy } from 'svelte';
|
||||||
import Tooltip from '$lib/components/Tooltip.svelte';
|
import Tooltip from '$lib/components/Tooltip.svelte';
|
||||||
import { status } from '$lib/store';
|
|
||||||
import { goto } from '$app/navigation';
|
|
||||||
|
|
||||||
let application: any = {};
|
let application: any = {};
|
||||||
let logsLoading = false;
|
let logsLoading = false;
|
||||||
@ -19,6 +17,8 @@
|
|||||||
let position = 0;
|
let position = 0;
|
||||||
let services: any = [];
|
let services: any = [];
|
||||||
let selectedService: any = null;
|
let selectedService: any = null;
|
||||||
|
let noContainer = false;
|
||||||
|
|
||||||
const { id } = $page.params;
|
const { id } = $page.params;
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const response = await get(`/applications/${id}`);
|
const response = await get(`/applications/${id}`);
|
||||||
@ -33,7 +33,7 @@
|
|||||||
name: ''
|
name: ''
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
await selectService('')
|
await selectService('');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
@ -50,27 +50,17 @@
|
|||||||
}
|
}
|
||||||
return tempdockerComposeServices;
|
return tempdockerComposeServices;
|
||||||
}
|
}
|
||||||
async function loadAllLogs() {
|
|
||||||
try {
|
|
||||||
logsLoading = true;
|
|
||||||
const data: any = await get(`/applications/${id}/logs`);
|
|
||||||
if (data?.logs) {
|
|
||||||
lastLog = data.logs[data.logs.length - 1];
|
|
||||||
logs = data.logs;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
return errorNotification(error);
|
|
||||||
} finally {
|
|
||||||
logsLoading = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function loadLogs() {
|
async function loadLogs() {
|
||||||
if (logsLoading) return;
|
if (logsLoading) return;
|
||||||
try {
|
try {
|
||||||
const newLogs: any = await get(
|
const newLogs: any = await get(
|
||||||
`/applications/${id}/logs/${selectedService}?since=${lastLog?.split(' ')[0] || 0}`
|
`/applications/${id}/logs/${selectedService}?since=${lastLog?.split(' ')[0] || 0}`
|
||||||
);
|
);
|
||||||
|
if (newLogs.noContainer) {
|
||||||
|
noContainer = true;
|
||||||
|
} else {
|
||||||
|
noContainer = false;
|
||||||
|
}
|
||||||
if (newLogs?.logs && newLogs.logs[newLogs.logs.length - 1] !== logs[logs.length - 1]) {
|
if (newLogs?.logs && newLogs.logs[newLogs.logs.length - 1] !== logs[logs.length - 1]) {
|
||||||
logs = logs.concat(newLogs.logs);
|
logs = logs.concat(newLogs.logs);
|
||||||
lastLog = newLogs.logs[newLogs.logs.length - 1];
|
lastLog = newLogs.logs[newLogs.logs.length - 1];
|
||||||
@ -103,7 +93,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function selectService(service: any, init: boolean = false) {
|
async function selectService(service: any, init: boolean = false) {
|
||||||
if (services.length === 1 && init) return
|
if (services.length === 1 && init) return;
|
||||||
|
|
||||||
if (loadLogsInterval) clearInterval(loadLogsInterval);
|
if (loadLogsInterval) clearInterval(loadLogsInterval);
|
||||||
if (followingInterval) clearInterval(followingInterval);
|
if (followingInterval) clearInterval(followingInterval);
|
||||||
@ -143,7 +133,9 @@
|
|||||||
{#if selectedService}
|
{#if selectedService}
|
||||||
<div class="flex flex-row justify-center space-x-2">
|
<div class="flex flex-row justify-center space-x-2">
|
||||||
{#if logs.length === 0}
|
{#if logs.length === 0}
|
||||||
<div class="text-xl font-bold tracking-tighter">{$t('application.build.waiting_logs')}</div>
|
{#if noContainer}
|
||||||
|
<div class="text-xl font-bold tracking-tighter">Container not found / exited.</div>
|
||||||
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
<div class="relative w-full">
|
<div class="relative w-full">
|
||||||
<div class="flex justify-start sticky space-x-2 pb-2">
|
<div class="flex justify-start sticky space-x-2 pb-2">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user