Skip to content

Hono + Bun graceful shutdown, handling SIGTERM #3731

Answered by seepine
amikofalvy asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, i try it and can work on development

import { Hono } from "hono";

const app = new Hono({ strict: false });

const server = Bun.serve({
  port: 3000,
  fetch: app.fetch,
});

process.once("SIGINT", async () => {
  console.log("shutdown event");
  await new Promise<void>((RES) => setTimeout(RES, 3000));
  console.log("shutdown done");
  server.stop();
  process.exit(0);
});

export default server;

But run with docker, it got error

 7 |       if (typeof entryNamespace?.default?.fetch === 'function')  {
 8 |         const server = Bun.serve(entryNamespace.default);
 9 |         console.debug(`Started ${server.development ? 'development ' : ''}server: ${server.protocol}://${server.hostnam…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@seepine
Comment options

Answer selected by amikofalvy
@seepine
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants