mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
Co-authored-by: Kai Tamkun <kai@tamkun.io> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: Ashcon Partovi <ashcon@partovi.net> Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com> Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Co-authored-by: 190n <190n@users.noreply.github.com>
24 lines
522 B
JavaScript
24 lines
522 B
JavaScript
'use strict';
|
|
const net = require('net');
|
|
|
|
const options = { port: 0, reusePort: true };
|
|
|
|
function checkSupportReusePort() {
|
|
return new Promise((resolve, reject) => {
|
|
const server = net.createServer().listen(options);
|
|
server.on('listening', () => {
|
|
server.close(resolve);
|
|
});
|
|
server.on('error', (err) => {
|
|
console.log('The `reusePort` option is not supported:', err.message);
|
|
server.close();
|
|
reject(err);
|
|
});
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
checkSupportReusePort,
|
|
options,
|
|
};
|