mirror of
https://github.com/KevinMidboe/infra-map.git
synced 2026-02-11 10:49:22 +00:00
26 lines
698 B
TypeScript
26 lines
698 B
TypeScript
import { createLogStream } from '$lib/server/kubernetes';
|
|
import { produce } from 'sveltekit-sse';
|
|
|
|
export function GET({ request }) {
|
|
return produce(async function start({ emit }) {
|
|
const url = new URL(request.url);
|
|
const pod = url.searchParams.get('pod');
|
|
const namespace = url.searchParams.get('namespace');
|
|
const container = url.searchParams.get('container');
|
|
|
|
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;
|
|
}
|
|
});
|
|
}
|