From 75041215b306fd5b7e7a86c2b0f35e5590010dea Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 14 Sep 2023 11:39:56 +0200 Subject: Log server info at startup --- src/index.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 69a7d86..2818682 100644 --- a/src/index.ts +++ b/src/index.ts @@ -129,7 +129,7 @@ function parseIfModifiedSinceHeader(header: string | null): number { return header ? new Date(header).getTime() + 999 : 0; } -Bun.serve({ +const metricsServer = Bun.serve({ port: 9091, fetch: async function (request) { const pathname = new URL(request.url).pathname; @@ -142,7 +142,11 @@ Bun.serve({ }, }); -export default { +console.info( + `Serving metrics on http://${metricsServer.hostname}:${metricsServer.port}/metrics`, +); + +const server = Bun.serve({ fetch: async function (request) { const pathname = new URL(request.url).pathname; const file = files.get(pathname); @@ -183,4 +187,6 @@ export default { } return serveFile(file); }, -} satisfies Serve; +}); + +console.info(`Serving website on http://${server.hostname}:${server.port}/`); -- cgit 1.4.1