diff --git a/frameworks/TypeScript/brahma-firelight/benchmark_config.json b/frameworks/TypeScript/brahma-firelight/benchmark_config.json index 5ebbb896e7e..60db94104a9 100644 --- a/frameworks/TypeScript/brahma-firelight/benchmark_config.json +++ b/frameworks/TypeScript/brahma-firelight/benchmark_config.json @@ -1,21 +1,23 @@ { "framework": "brahma-firelight", - "tests": [{ - "default": { - "json_url": "/json", - "plaintext_url": "/plaintext", - "port": 8080, - "approach": "Realistic", - "classification": "Micro", - "framework": "brahma-firelight", - "language": "TypeScript", - "flavor": "bun", - "platform": "bun", - "webserver": "None", - "os": "Linux", - "database_os": "Linux", - "display_name": "brahma-firelight", - "versus": "nodejs" + "tests": [ + { + "default": { + "json_url": "/json", + "plaintext_url": "/plaintext", + "port": 8080, + "approach": "Realistic", + "classification": "Micro", + "framework": "brahma-firelight", + "language": "TypeScript", + "flavor": "bun", + "platform": "bun", + "webserver": "None", + "os": "Linux", + "database_os": "Linux", + "display_name": "brahma-firelight", + "versus": "nodejs" + } } - }] + ] } diff --git a/frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile b/frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile index dd682eba23f..4ae04a5efbf 100644 --- a/frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile +++ b/frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile @@ -1,13 +1,25 @@ -FROM oven/bun:1.3 - +FROM oven/bun:1.3 AS builder WORKDIR /app -COPY . . +COPY package.json bun.lock ./ -RUN bun install +RUN bun ci +COPY . . RUN bun run build +FROM oven/bun:1.3 AS runtime +WORKDIR /app + +ENV NODE_ENV=production +ENV PORT=8080 + +COPY --from=builder /app/dist ./dist +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/package.json ./package.json + +ENV NODE_ENV=production + EXPOSE 8080 -CMD ["bun", "dist/main.js"] +ENTRYPOINT ["bun", "dist/main.js"] diff --git a/frameworks/TypeScript/brahma-firelight/bun.lock b/frameworks/TypeScript/brahma-firelight/bun.lock index a24e46c51c5..067ff9b71e3 100644 --- a/frameworks/TypeScript/brahma-firelight/bun.lock +++ b/frameworks/TypeScript/brahma-firelight/bun.lock @@ -4,7 +4,7 @@ "": { "name": "brahma-firelight", "dependencies": { - "brahma-firelight": "1.5.16", + "brahma-firelight": "^1.5.18", }, "devDependencies": { "@types/bun": "latest", @@ -21,7 +21,7 @@ "@types/react": ["@types/react@19.2.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="], - "brahma-firelight": ["brahma-firelight@1.5.16", "", {}, "sha512-KwqrG3EHBcEYiOjjx7UvZ4TDxnKTP+DPjnQQqblKuHQcS/mw35NzIYf01YnBZLRM/9VZrb5+UrDaNmrAPZGYlw=="], + "brahma-firelight": ["brahma-firelight@1.5.18", "", {}, "sha512-/raDDeb6/AAHYPfvTi4vWA79BjsHwh5Eg63GWJPwWzyip3mvY0tIsNeMqHit4XBdyJZ9t0UgtsvNaHGx3zqFGw=="], "bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="], diff --git a/frameworks/TypeScript/brahma-firelight/package.json b/frameworks/TypeScript/brahma-firelight/package.json index dbe9f089100..c7b49a791fd 100644 --- a/frameworks/TypeScript/brahma-firelight/package.json +++ b/frameworks/TypeScript/brahma-firelight/package.json @@ -14,6 +14,6 @@ "typescript": "^5" }, "dependencies": { - "brahma-firelight": "1.5.16" + "brahma-firelight": "^1.5.18" } } \ No newline at end of file diff --git a/frameworks/TypeScript/brahma-firelight/src/main.ts b/frameworks/TypeScript/brahma-firelight/src/main.ts index 639d33f3085..3583f916605 100644 --- a/frameworks/TypeScript/brahma-firelight/src/main.ts +++ b/frameworks/TypeScript/brahma-firelight/src/main.ts @@ -1,10 +1,13 @@ import { createApp, type Response, type Request, type App, type NextFunction, type Handler } from "brahma-firelight"; +import cluster from "node:cluster"; +import os from "node:os"; const app: App = createApp(); // Server Config Middleware const serverInfo: Handler = (_req: Request, res: Response, next?: NextFunction) => { res.setHeader("Server", "brahma-firelight"); + res.setHeader("Connection", "keep-alive") next?.(); }; @@ -19,19 +22,39 @@ app.get("/plaintext", serverInfo, (_req: Request, res: Response) => { }); // Port & Host - -app.listen("0.0.0.0", 8080); - -// Enable built in Graceful Shutdown (optional for production use) - -process.on('SIGINT', async () => { - console.log('SIGINT → shutting down...'); - await app.close(2000); // wait up to 2s for requests - process.exit(0); -}); - -process.on('SIGTERM', async () => { - console.log('SIGTERM → shutting down...'); - await app.close(2000); - process.exit(0); -}); \ No newline at end of file +const PORT = process.env.PORT || 8080; +const HOST = process.env.HOST || "0.0.0.0"; + +// Single CORE +//app.listen(HOST, +PORT); + +// Multi CORE (cluster with max cpus available) +if (cluster.isPrimary) { + const cpuCount = os.cpus().length; + console.log(`Primary ${process.pid} running → forking ${cpuCount} workers...`); + + for (let i = 0; i < cpuCount; i++) { + cluster.fork(); + } + + cluster.on("exit", (worker) => { + console.log(`Worker ${worker.process.pid} died → restarting...`); + cluster.fork(); + }); +} else { + app.listen(HOST, +PORT); +} + +// // Enable built in Graceful Shutdown (optional for production use) + +// process.on('SIGINT', async () => { +// console.log('SIGINT → shutting down...'); +// await app.close(2000); // wait up to 2s for requests +// process.exit(0); +// }); + +// process.on('SIGTERM', async () => { +// console.log('SIGTERM → shutting down...'); +// await app.close(2000); +// process.exit(0); +// }); \ No newline at end of file