fix: try a different way to listen for the server shutdown and remove

signal listeners
This commit is contained in:
Andy Burke 2025-07-23 17:05:33 -07:00
parent 4f2ea38222
commit f63cb933dd
2 changed files with 10 additions and 6 deletions

View file

@ -196,10 +196,15 @@ export class SERVER {
*/
public async stop(): Promise<void> {
if (this.server) {
if (this.shutdown_binding) {
Deno.removeSignalListener('SIGTERM', this.shutdown_binding);
Deno.removeSignalListener('SIGINT', this.shutdown_binding);
}
this.server.finished.finally(() => {
if (this.shutdown_binding) {
Deno.removeSignalListener('SIGTERM', this.shutdown_binding);
Deno.removeSignalListener('SIGINT', this.shutdown_binding);
}
this.shutdown_binding = undefined;
});
this.controller?.abort();
await this.server.shutdown();
}
@ -210,7 +215,6 @@ export class SERVER {
this.controller = undefined;
this.server = undefined;
this.shutdown_binding = undefined;
this.original_directory = undefined;
for (const handler_module of this.handlers) {