Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions frameworks/TypeScript/brahma-firelight/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}]
]
}
22 changes: 17 additions & 5 deletions frameworks/TypeScript/brahma-firelight/brahma-firelight.dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 2 additions & 2 deletions frameworks/TypeScript/brahma-firelight/bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"": {
"name": "brahma-firelight",
"dependencies": {
"brahma-firelight": "1.5.16",
"brahma-firelight": "^1.5.18",
},
"devDependencies": {
"@types/bun": "latest",
Expand All @@ -21,7 +21,7 @@

"@types/react": ["@types/[email protected]", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="],

"brahma-firelight": ["[email protected].16", "", {}, "sha512-KwqrG3EHBcEYiOjjx7UvZ4TDxnKTP+DPjnQQqblKuHQcS/mw35NzIYf01YnBZLRM/9VZrb5+UrDaNmrAPZGYlw=="],
"brahma-firelight": ["[email protected].18", "", {}, "sha512-/raDDeb6/AAHYPfvTi4vWA79BjsHwh5Eg63GWJPwWzyip3mvY0tIsNeMqHit4XBdyJZ9t0UgtsvNaHGx3zqFGw=="],

"bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="],

Expand Down
2 changes: 1 addition & 1 deletion frameworks/TypeScript/brahma-firelight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"typescript": "^5"
},
"dependencies": {
"brahma-firelight": "1.5.16"
"brahma-firelight": "^1.5.18"
}
}
55 changes: 39 additions & 16 deletions frameworks/TypeScript/brahma-firelight/src/main.ts
Original file line number Diff line number Diff line change
@@ -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?.();
};

Expand All @@ -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);
});
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);
// });
Loading