Replies: 1 comment
-
|
To properly exit const controller = new AbortController();
const { signal } = controller;
Deno.serve({ signal }, async (req) => {
return new Response("Hello World");
});
Deno.addSignalListener("SIGINT", async () => {
console.log("Caught SIGINT, shutting down...");
controller.abort(); // Gracefully shut down server
await client.destroy();
db.close();
kv.close();
Deno.exit(0); // Ensure zero exit code
});Hope it helps! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to build a service which is composed of multiple components, with a Deno.serve base web server.
I want to have a zero exit code and I want to handle SIGINT from a signal listener (Deno.addSignalListener) to call the methods closing the different components. While other components work fine with this setup, Deno.serve seems to handle the signal himself and return a 130 code:
It look like this in the console, so basically returning the error code (that I didn't ask for) and then the output still get printed? :
Beta Was this translation helpful? Give feedback.
All reactions