node should work better on pis

This commit is contained in:
lone-cloud 2026-01-28 23:54:08 -08:00
parent 47f431a3e3
commit 231966010f
2 changed files with 29 additions and 26 deletions

View file

@ -1,6 +1,6 @@
FROM oven/bun:1.3.7-debian FROM node:alpine
RUN apt-get update && apt-get install -y nginx docker.io && rm -rf /var/lib/apt/lists/* RUN apk add --no-cache nginx docker-cli
COPY nginx.conf /etc/nginx/nginx.conf COPY nginx.conf /etc/nginx/nginx.conf
COPY index.html /usr/share/nginx/html/index.html COPY index.html /usr/share/nginx/html/index.html
@ -10,7 +10,7 @@ COPY logs-server.js /app/logs-server.js
RUN echo '#!/bin/sh' > /start.sh && \ RUN echo '#!/bin/sh' > /start.sh && \
echo 'nginx' >> /start.sh && \ echo 'nginx' >> /start.sh && \
echo 'cd /app && bun logs-server.js' >> /start.sh && \ echo 'cd /app && node logs-server.js' >> /start.sh && \
chmod +x /start.sh chmod +x /start.sh
EXPOSE 8888 EXPOSE 8888

View file

@ -1,28 +1,31 @@
Bun.serve({ const http = require("node:http");
port: 3001, const { spawn } = require("node:child_process");
async fetch() {
try { http
const proc = Bun.spawn( .createServer((_req, res) => {
["docker", "logs", "--tail", "100", "snowflake-proxy"], const proc = spawn("docker", ["logs", "--tail", "100", "snowflake-proxy"]);
{
stdout: "pipe", let output = "";
stderr: "pipe", proc.stdout.on("data", (data) => {
}, output += data;
); });
const output = await new Response(proc.stdout).text(); proc.stderr.on("data", (data) => {
const errors = await new Response(proc.stderr).text(); output += data;
const logs = (output + errors) });
proc.on("close", () => {
const logs = output
.split("\n") .split("\n")
.filter((line) => line.includes("In the last")) .filter((line) => line.includes("In the last"))
.join("\n"); .join("\n");
return new Response(logs, { res.writeHead(200, { "Content-Type": "text/plain" });
headers: { "Content-Type": "text/plain" }, res.end(logs);
}); });
} catch {
return new Response("Logs unavailable", { status: 500 });
}
},
});
console.log("Logs server running on port 3001"); proc.on("error", () => {
res.writeHead(500);
res.end("Logs unavailable");
});
})
.listen(3001, () => console.log("Logs server running on port 3001"));