Skip to content

Instantly share code, notes, and snippets.

@Holi0317
Created June 24, 2025 15:21
Show Gist options
  • Select an option

  • Save Holi0317/215f2e0eadecf727fdf74a4efd10bda7 to your computer and use it in GitHub Desktop.

Select an option

Save Holi0317/215f2e0eadecf727fdf74a4efd10bda7 to your computer and use it in GitHub Desktop.
Nginx unit timeout
{
"listeners": {
"*:80": {
"pass": "applications/express"
}
},
"applications": {
"express": {
"type": "external",
"working_directory": "/app",
"executable": "/usr/bin/env",
"arguments": [
"node",
"--loader",
"unit-http/loader.mjs",
"--require",
"unit-http/loader",
"main.js"
],
"limits": {
"timeout": 15
}
}
}
}
FROM unit:1.34.2-node22
COPY package.json package-lock.json /app/
WORKDIR /app
RUN npm install
RUN npm install unit-http
COPY main.js /app/
COPY conf.json /docker-entrypoint.d/config.json
// @ts-check
import { Hono } from "hono";
import { streamText } from "hono/streaming";
import { serve } from "@hono/node-server";
const app = new Hono();
app.get("/", (c) => {
return streamText(c, async (stream) => {
console.log(`${new Date()} UwU 1`);
await stream.writeln("1");
await stream.sleep(10000);
console.log(`${new Date()} UwU 2`);
await stream.writeln("2");
await stream.sleep(10000);
console.log(`${new Date()} UwU 2`);
await stream.writeln("3");
});
});
serve({
fetch: app.fetch,
port: 8080,
});
{
"name": "unittimeout",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "unittimeout",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@hono/node-server": "^1.14.4",
"hono": "^4.8.2"
}
},
"node_modules/@hono/node-server": {
"version": "1.14.4",
"resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.14.4.tgz",
"integrity": "sha512-DnxpshhYewr2q9ZN8ez/M5mmc3sucr8CT1sIgIy1bkeUXut9XWDkqHoFHRhWIQgkYnKpVRxunyhK7WzpJeJ6qQ==",
"license": "MIT",
"engines": {
"node": ">=18.14.1"
},
"peerDependencies": {
"hono": "^4"
}
},
"node_modules/hono": {
"version": "4.8.2",
"resolved": "https://registry.npmjs.org/hono/-/hono-4.8.2.tgz",
"integrity": "sha512-hM+1RIn9PK1I6SiTNS6/y7O1mvg88awYLFEuEtoiMtRyT3SD2iu9pSFgbBXT3b1Ua4IwzvSTLvwO0SEhDxCi4w==",
"license": "MIT",
"engines": {
"node": ">=16.9.0"
}
}
}
}
{
"name": "unittimeout",
"version": "1.0.0",
"description": "",
"type": "module",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@hono/node-server": "^1.14.4",
"hono": "^4.8.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment