From 0d7a3f22edabf680b098fc89337fd7f21088fbdd Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Sun, 25 Jan 2026 14:32:22 -0500 Subject: Support systemd socket activation --- cgithub/src/index.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'cgithub/src/index.ts') diff --git a/cgithub/src/index.ts b/cgithub/src/index.ts index c934530..525ac74 100644 --- a/cgithub/src/index.ts +++ b/cgithub/src/index.ts @@ -1,4 +1,4 @@ -import { serve } from "@hono/node-server"; +import { createAdaptorServer, serve } from "@hono/node-server"; import { serveStatic } from "@hono/node-server/serve-static"; import { Eta } from "eta"; import { Hono } from "hono"; @@ -55,7 +55,15 @@ app.get("/:owner/:repo/blob/:branch/:path{.*}", async (c) => { } }); -const port = parseInt(process.env.PORT || "3000", 10); -serve({ fetch: app.fetch, port }, (info) => { - console.log(`Server running on http://localhost:${info.port}`); -}); +if (process.env.LISTEN_FDS === "1") { + const server = createAdaptorServer(app); + // Listen on SD_LISTEN_FDS_START. + server.listen({ fd: 3 }, () => { + console.log("Server running via systemd socket activation"); + }); +} else { + const port = parseInt(process.env.PORT || "3000", 10); + serve({ fetch: app.fetch, port }, (info) => { + console.log(`Server running on http://localhost:${info.port}`); + }); +} -- cgit v1.3.1