Skip to content

Commit 71db3c8

Browse files
add upload cli logs via lsrs in stop endpoint
1 parent c5dc388 commit 71db3c8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/lib/server.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { validateSnapshot } from './schemaValidation.js'
77
import { pingIntervalId } from './utils.js';
88
import { startPolling } from './utils.js';
99

10+
const uploadDomToS3ViaEnv = process.env.USE_LAMBDA_INTERNAL || false;
1011
export default async (ctx: Context): Promise<FastifyInstance<Server, IncomingMessage, ServerResponse>> => {
1112

1213
const server: FastifyInstance<Server, IncomingMessage, ServerResponse> = fastify({
@@ -105,8 +106,16 @@ export default async (ctx: Context): Promise<FastifyInstance<Server, IncomingMes
105106
if (ctx.server){
106107
ctx.server.close();
107108
}
108-
let resp = await ctx.client.getS3PreSignedURL(ctx);
109-
await ctx.client.uploadLogs(ctx, resp.data.url);
109+
110+
let uploadCLILogsToS3 = ctx?.config?.useLambdaInternal || uploadDomToS3ViaEnv;
111+
if (!uploadCLILogsToS3) {
112+
ctx.log.debug(`Log file to be uploaded`)
113+
let resp = await ctx.client.getS3PreSignedURL(ctx);
114+
await ctx.client.uploadLogs(ctx, resp.data.url);
115+
} else {
116+
ctx.log.debug(`Log file to be uploaded via LSRS`)
117+
let resp = ctx.client.sendCliLogsToLSRS(ctx);
118+
}
110119

111120
if (pingIntervalId !== null) {
112121
clearInterval(pingIntervalId);

0 commit comments

Comments
 (0)