mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-24 12:33:17 +00:00
29 lines
725 B
TypeScript
29 lines
725 B
TypeScript
import { saveServerLog } from '$lib/api/applications/logging';
|
|
import { docker } from '$lib/api/docker';
|
|
import type { Request } from '@sveltejs/kit';
|
|
|
|
export async function get(request: Request) {
|
|
try {
|
|
const name = request.query.get('name');
|
|
const service = await docker.engine.getService(`${name}_${name}`);
|
|
const logs = (await service.logs({ stdout: true, stderr: true, timestamps: true }))
|
|
.toString()
|
|
.split('\n')
|
|
.map((l) => l.slice(8))
|
|
.filter((a) => a);
|
|
return {
|
|
status: 200,
|
|
body: { success: true, logs }
|
|
};
|
|
} catch (error) {
|
|
console.log(error);
|
|
await saveServerLog(error);
|
|
return {
|
|
status: 500,
|
|
body: {
|
|
error: 'No such service. Is it under deployment?'
|
|
}
|
|
};
|
|
}
|
|
}
|