FreeBSD build #1193
Replies: 4 comments 1 reply
-
|
I am now publishing builds here: https://github.com/louwers/uws-freebsd/releases Will automatically update when uWebsockets.js makes a new release. |
Beta Was this translation helpful? Give feedback.
-
|
I have now set up CI with weekly cron, so should stay up to date in the future. |
Beta Was this translation helpful? Give feedback.
-
|
I think we used to have FreeBSD support at some time but it stopped working after some changes and was dropped because you can't even download Node.js for FreeBSD from nodejs.org - only Windows, macOS and Linux (and some AIX thing, wtf?). So the problem is not so much about compiling it, it's that once it is added it needs fixing when it breaks and the extra time sink is not worth it. Very clean and legally correct fork you did, anyways. It's not entirely impossible to add FreeBSD here at some point but very unlikely (GitHub Actions don't even have a FreeBSD runner). It's too niche |
Beta Was this translation helpful? Give feedback.
-
|
I am using this postinstall script to copy my FreeBSD build to the directory where uWebSocket.js looks for binaries. Just add it to Feel free to use it, available under CC0. Probably too simple to distribute as a library. import { findPackageJSON } from "node:module";
import { createWriteStream, readFileSync } from "node:fs";
import { join, dirname } from "node:path";
import { platform, arch } from "node:os";
import { Readable } from "node:stream";
import { pipeline } from "node:stream/promises";
import { ReadableStream as WebReadableStream } from "node:stream/web";
async function downloadFreeBSDBinary(): Promise<void> {
if (platform() !== "freebsd") {
console.log("Not running on FreeBSD, skipping binary download");
return;
}
if (arch() !== "x64") {
console.error(
`Unsupported architecture: ${arch()}. Only x64 is supported.`,
);
process.exit(1);
}
try {
const abiVersion = process.versions.modules;
const uwsPackageJson = findPackageJSON("uWebSockets.js", import.meta.url);
if (!uwsPackageJson) {
console.error("Could not find uWebSockets.js package.json");
process.exit(1);
}
const packageContent = readFileSync(uwsPackageJson, "utf-8");
const packageData = JSON.parse(packageContent);
const version = packageData.version;
console.log(`Found uWebSockets.js version: ${version}`);
// Download URL for FreeBSD binary
const downloadUrl = `https://github.com/louwers/uws-freebsd/releases/download/v${version}/uws_freebsd_x64_${abiVersion}.node`;
const packageDir = dirname(uwsPackageJson);
const outputPath = join(packageDir, `uws_freebsd_x64_${abiVersion}.node`);
console.log(`Downloading FreeBSD binary from: ${downloadUrl}`);
console.log(`Saving to: ${outputPath}`);
const response = await fetch(downloadUrl);
if (!response.ok) {
throw new Error(
`Failed to download: ${response.status} ${response.statusText}`,
);
}
if (!response.body) {
throw new Error("Download failed: empty response body");
}
const readable = Readable.fromWeb(
response.body as unknown as WebReadableStream<Uint8Array>,
);
await pipeline(readable, createWriteStream(outputPath));
console.log("Successfully downloaded FreeBSD binary for uWebSockets.js");
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.error("Error downloading FreeBSD binary:", message);
process.exit(1);
}
}
try {
await downloadFreeBSDBinary();
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.error("Unexpected error:", message);
process.exit(1);
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Occasionally people ask about FreeBSD.
It works, you just have to add
to
build.cCreated a release here: https://github.com/louwers/uws-freebsd/releases
Beta Was this translation helpful? Give feedback.
All reactions