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