mirror of
https://github.com/KevinMidboe/infra-map.git
synced 2026-02-15 04:39:24 +00:00
working nice. docker uses bun
This commit is contained in:
27
src/routes/cluster/[resource]/[uid]/logs/+server.ts
Normal file
27
src/routes/cluster/[resource]/[uid]/logs/+server.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { createLogStream } from '$lib/server/kubernetes';
|
||||
import { produce } from 'sveltekit-sse';
|
||||
|
||||
export function GET({ request }) {
|
||||
return produce(async function start({ emit }) {
|
||||
console.log('----- REQUEST -----');
|
||||
const url = new URL(request.url);
|
||||
const pod = url.searchParams.get('pod');
|
||||
const namespace = url.searchParams.get('namespace');
|
||||
const container = url.searchParams.get('container');
|
||||
|
||||
console.log('pod, namespace:', pod, namespace);
|
||||
const k8sLogs = createLogStream(pod, namespace, container);
|
||||
k8sLogs.start();
|
||||
const unsubscribe = k8sLogs.logEmitter.subscribe((msg: string) => {
|
||||
emit('message', msg);
|
||||
});
|
||||
|
||||
const { error } = emit('message', `the time is ${Date.now()}`);
|
||||
|
||||
if (error) {
|
||||
k8sLogs.stop();
|
||||
unsubscribe();
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user