node-server icon indicating copy to clipboard operation
node-server copied to clipboard

How to destroy/close server ?

Open promentol opened this issue 2 years ago • 2 comments

Express.js servers have close method

How to destroy http server created by serve function ?

serve({
        fetch: honoServer.fetch,
        port: 3001,
      })

promentol avatar Sep 29 '23 13:09 promentol

You can call server.close():

  const server = serve(options, ({ address, port }) => {
    console.log(`Server listening at http://${address}:${port}`);
  });

  process.on("SIGINT", () => {
    console.log("Ctrl-C was pressed");
    server.close();
  });

mgcrea avatar Oct 18 '23 08:10 mgcrea