diff options
| author | Joe Mou <dev@mou.fo> | 2026-01-25 14:32:22 -0500 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-01-25 17:46:15 -0500 |
| commit | 0d7a3f22edabf680b098fc89337fd7f21088fbdd (patch) | |
| tree | 31ae6bec9365eb165c76c24b61eaa613231fc29d /cgithub | |
| parent | b8784e25b76039c1ce0cfedee6aa50d5446579f9 (diff) | |
Support systemd socket activation
Diffstat (limited to 'cgithub')
| -rw-r--r-- | cgithub/src/index.ts | 18 |
1 files changed, 13 insertions, 5 deletions
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}`); + }); +} |
