mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
27 lines
600 B
JavaScript
Generated
27 lines
600 B
JavaScript
Generated
let existingPromise = null;
|
|
const server = Bun.serve({
|
|
port: 0,
|
|
async fetch(req) {
|
|
if (!existingPromise) {
|
|
existingPromise = Bun.sleep(0);
|
|
}
|
|
let waitedUpon = existingPromise;
|
|
await existingPromise;
|
|
if (existingPromise === waitedUpon) {
|
|
existingPromise = null;
|
|
}
|
|
return new Response(process.memoryUsage.rss().toString());
|
|
},
|
|
});
|
|
|
|
setInterval(() => {
|
|
console.log("RSS", (process.memoryUsage.rss() / 1024 / 1024) | 0);
|
|
}, 1000);
|
|
console.log("Server started on", server.url.href);
|
|
|
|
if (process.channel) {
|
|
process.send({
|
|
url: server.url.href,
|
|
});
|
|
}
|