mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: 190n <190n@users.noreply.github.com> Co-authored-by: 190n <7763597+190n@users.noreply.github.com>
21 lines
648 B
JavaScript
Generated
21 lines
648 B
JavaScript
Generated
import { createServer } from "http";
|
|
const SIGNAL = process.platform === "linux" ? "SIGUSR2" : "SIGUSR1";
|
|
var server = createServer((req, res) => {
|
|
res.end();
|
|
}).listen(0, async (err, hostname, port) => {
|
|
process.on(SIGNAL, async () => {
|
|
server.unref();
|
|
|
|
// check that the server is still running
|
|
const resp = await fetch(`http://localhost:${port}`);
|
|
await resp.arrayBuffer();
|
|
console.log("Unref'd & server still running (as expected)");
|
|
});
|
|
const resp = await fetch(`http://localhost:${port}`);
|
|
await resp.arrayBuffer();
|
|
if (resp.status !== 200) {
|
|
process.exit(42);
|
|
}
|
|
process.kill(process.pid, SIGNAL);
|
|
});
|