feat: Query container state periodically
This commit is contained in:
parent
65c8f55ee6
commit
e16643c48c
@ -75,15 +75,18 @@
|
||||
import { errorNotification } from '$lib/form';
|
||||
import DeleteIcon from '$lib/components/DeleteIcon.svelte';
|
||||
import Loading from '$lib/components/Loading.svelte';
|
||||
import { del, post } from '$lib/api';
|
||||
import { del, get, post } from '$lib/api';
|
||||
import { goto } from '$app/navigation';
|
||||
import { gitTokens } from '$lib/store';
|
||||
import { toast } from '@zerodevx/svelte-toast';
|
||||
import { disabledButton } from '$lib/store';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
|
||||
if (githubToken) $gitTokens.githubToken = githubToken;
|
||||
if (gitlabToken) $gitTokens.gitlabToken = gitlabToken;
|
||||
|
||||
let loading = false;
|
||||
let statusInterval;
|
||||
$disabledButton =
|
||||
!$session.isAdmin ||
|
||||
!application.fqdn ||
|
||||
@ -130,6 +133,19 @@
|
||||
return errorNotification(error);
|
||||
}
|
||||
}
|
||||
async function getStatus() {
|
||||
statusInterval = setInterval(async () => {
|
||||
const data = await get(`/applications/${id}.json`);
|
||||
isRunning = data.isRunning;
|
||||
isExited = data.isExited;
|
||||
}, 1000);
|
||||
}
|
||||
onDestroy(() => {
|
||||
clearInterval(statusInterval);
|
||||
});
|
||||
onMount(async () => {
|
||||
await getStatus();
|
||||
});
|
||||
</script>
|
||||
|
||||
<nav class="nav-side">
|
||||
|
@ -65,9 +65,9 @@ export const post: RequestHandler = async (event) => {
|
||||
denoOptions
|
||||
} = await event.request.json();
|
||||
if (port) port = Number(port);
|
||||
if (denoOptions) denoOptions = denoOptions.trim();
|
||||
|
||||
try {
|
||||
console.log(buildPack);
|
||||
const defaultConfiguration = await setDefaultConfiguration({
|
||||
buildPack,
|
||||
port,
|
||||
|
@ -21,12 +21,11 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { changeQueryParams, dateOptions, getDomain } from '$lib/components/common';
|
||||
import { changeQueryParams, dateOptions } from '$lib/components/common';
|
||||
|
||||
import BuildLog from './_BuildLog.svelte';
|
||||
import { get } from '$lib/api';
|
||||
import { errorNotification } from '$lib/form';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
export let builds;
|
||||
export let application;
|
||||
|
@ -22,7 +22,9 @@ export const get: RequestHandler = async (event) => {
|
||||
if (container) {
|
||||
return {
|
||||
body: {
|
||||
logs: (await container.logs({ stdout: true, stderr: true, timestamps: true }))
|
||||
logs: (
|
||||
await container.logs({ stdout: true, stderr: true, timestamps: true, tail: 5000 })
|
||||
)
|
||||
.toString()
|
||||
.split('\n')
|
||||
.map((l) => l.slice(8))
|
||||
|
Loading…
x
Reference in New Issue
Block a user