From cb630a095b15da5bbd42a02e8e3f10e91f1a2548 Mon Sep 17 00:00:00 2001 From: Andy Burke Date: Wed, 23 Jul 2025 16:46:40 -0700 Subject: [PATCH] fix: try to make sure we unregister our signal listeners before we shutdown --- deno.json | 8 ++++---- deno.lock | 59 ++++++++++++++++++++++++------------------------------- server.ts | 3 +-- 3 files changed, 31 insertions(+), 39 deletions(-) diff --git a/deno.json b/deno.json index 415270c..b7eaace 100644 --- a/deno.json +++ b/deno.json @@ -1,7 +1,7 @@ { "name": "@andyburke/serverus", "description": "A flexible HTTP server for mixed content. Throw static files, markdown, Typescript and (hopefully, eventually) more into a directory and serverus can serve it up a bit more like old-school CGI.", - "version": "0.9.3", + "version": "0.9.4", "license": "MIT", "exports": { ".": "./serverus.ts", @@ -44,12 +44,12 @@ "imports": { "@std/assert": "jsr:@std/assert@^1.0.11", "@std/async": "jsr:@std/async@^1.0.13", - "@std/cli": "jsr:@std/cli@^1.0.20", + "@std/cli": "jsr:@std/cli@^1.0.21", "@std/fmt": "jsr:@std/fmt@^1.0.6", "@std/fs": "jsr:@std/fs@^1.0.19", - "@std/http": "jsr:@std/http@^1.0.19", + "@std/http": "jsr:@std/http@^1.0.20", "@std/media-types": "jsr:@std/media-types@^1.1.0", "@std/path": "jsr:@std/path@^1.1.1", - "@std/testing": "jsr:@std/testing@^1.0.14" + "@std/testing": "jsr:@std/testing@^1.0.15" } } diff --git a/deno.lock b/deno.lock index 27ce907..f32c7f3 100644 --- a/deno.lock +++ b/deno.lock @@ -5,25 +5,22 @@ "jsr:@std/assert@^1.0.13": "1.0.13", "jsr:@std/async@*": "1.0.11", "jsr:@std/async@^1.0.13": "1.0.13", - "jsr:@std/cli@^1.0.20": "1.0.20", - "jsr:@std/data-structures@^1.0.8": "1.0.8", + "jsr:@std/cli@^1.0.21": "1.0.21", + "jsr:@std/data-structures@^1.0.9": "1.0.9", "jsr:@std/encoding@^1.0.10": "1.0.10", "jsr:@std/fmt@^1.0.6": "1.0.8", "jsr:@std/fmt@^1.0.8": "1.0.8", - "jsr:@std/fs@^1.0.18": "1.0.19", "jsr:@std/fs@^1.0.19": "1.0.19", "jsr:@std/html@^1.0.4": "1.0.4", - "jsr:@std/http@^1.0.19": "1.0.19", - "jsr:@std/internal@*": "1.0.8", - "jsr:@std/internal@^1.0.6": "1.0.8", - "jsr:@std/internal@^1.0.8": "1.0.8", - "jsr:@std/internal@^1.0.9": "1.0.9", + "jsr:@std/http@^1.0.20": "1.0.20", + "jsr:@std/internal@^1.0.10": "1.0.10", + "jsr:@std/internal@^1.0.6": "1.0.10", + "jsr:@std/internal@^1.0.9": "1.0.10", "jsr:@std/media-types@^1.1.0": "1.1.0", "jsr:@std/net@^1.0.4": "1.0.4", - "jsr:@std/path@^1.1.0": "1.1.1", "jsr:@std/path@^1.1.1": "1.1.1", "jsr:@std/streams@^1.0.10": "1.0.10", - "jsr:@std/testing@^1.0.14": "1.0.14", + "jsr:@std/testing@^1.0.15": "1.0.15", "npm:@types/node@*": "22.15.15" }, "jsr": { @@ -39,11 +36,11 @@ "@std/async@1.0.13": { "integrity": "1d76ca5d324aef249908f7f7fe0d39aaf53198e5420604a59ab5c035adc97c96" }, - "@std/cli@1.0.20": { - "integrity": "a8c384a2c98cec6ec6a2055c273a916e2772485eb784af0db004c5ab8ba52333" + "@std/cli@1.0.21": { + "integrity": "cd25b050bdf6282e321854e3822bee624f07aca7636a3a76d95f77a3a919ca2a" }, - "@std/data-structures@1.0.8": { - "integrity": "2fb7219247e044c8fcd51341788547575653c82ae2c759ff209e0263ba7d9b66" + "@std/data-structures@1.0.9": { + "integrity": "033d6e17e64bf1f84a614e647c1b015fa2576ae3312305821e1a4cb20674bb4d" }, "@std/encoding@1.0.10": { "integrity": "8783c6384a2d13abd5e9e87a7ae0520a30e9f56aeeaa3bdf910a3eaaf5c811a1" @@ -55,31 +52,28 @@ "integrity": "051968c2b1eae4d2ea9f79a08a3845740ef6af10356aff43d3e2ef11ed09fb06", "dependencies": [ "jsr:@std/internal@^1.0.9", - "jsr:@std/path@^1.1.1" + "jsr:@std/path" ] }, "@std/html@1.0.4": { "integrity": "eff3497c08164e6ada49b7f81a28b5108087033823153d065e3f89467dd3d50e" }, - "@std/http@1.0.19": { - "integrity": "52128c8d00a1f0b20019f8b72376e7ef5f3133375b6f805b5bc89b9de2ad4686", + "@std/http@1.0.20": { + "integrity": "b5cc33fc001bccce65ed4c51815668c9891c69ccd908295997e983d8f56070a1", "dependencies": [ "jsr:@std/cli", "jsr:@std/encoding", "jsr:@std/fmt@^1.0.8", - "jsr:@std/fs@^1.0.19", + "jsr:@std/fs", "jsr:@std/html", "jsr:@std/media-types", "jsr:@std/net", - "jsr:@std/path@^1.1.1", + "jsr:@std/path", "jsr:@std/streams" ] }, - "@std/internal@1.0.8": { - "integrity": "fc66e846d8d38a47cffd274d80d2ca3f0de71040f855783724bb6b87f60891f5" - }, - "@std/internal@1.0.9": { - "integrity": "bdfb97f83e4db7a13e8faab26fb1958d1b80cc64366501af78a0aee151696eb8" + "@std/internal@1.0.10": { + "integrity": "e3be62ce42cab0e177c27698e5d9800122f67b766a0bea6ca4867886cbde8cf7" }, "@std/media-types@1.1.0": { "integrity": "c9d093f0c05c3512932b330e3cc1fe1d627b301db33a4c2c2185c02471d6eaa4" @@ -96,15 +90,14 @@ "@std/streams@1.0.10": { "integrity": "75c0b1431873cd0d8b3d679015220204d36d3c7420d93b60acfc379eb0dc30af" }, - "@std/testing@1.0.14": { - "integrity": "144b3737105b9071cb50c957681f58a1b8ec0f3e5b19ad830f401c5fa931e8f0", + "@std/testing@1.0.15": { + "integrity": "a490169f5ccb0f3ae9c94fbc69d2cd43603f2cffb41713a85f99bbb0e3087cbc", "dependencies": [ "jsr:@std/assert@^1.0.13", - "jsr:@std/async@^1.0.13", "jsr:@std/data-structures", - "jsr:@std/fs@^1.0.18", - "jsr:@std/internal@^1.0.8", - "jsr:@std/path@^1.1.0" + "jsr:@std/fs", + "jsr:@std/internal@^1.0.10", + "jsr:@std/path" ] } }, @@ -136,13 +129,13 @@ "dependencies": [ "jsr:@std/assert@^1.0.11", "jsr:@std/async@^1.0.13", - "jsr:@std/cli@^1.0.20", + "jsr:@std/cli@^1.0.21", "jsr:@std/fmt@^1.0.6", "jsr:@std/fs@^1.0.19", - "jsr:@std/http@^1.0.19", + "jsr:@std/http@^1.0.20", "jsr:@std/media-types@^1.1.0", "jsr:@std/path@^1.1.1", - "jsr:@std/testing@^1.0.14" + "jsr:@std/testing@^1.0.15" ] } } diff --git a/server.ts b/server.ts index 5a59dd3..3194e0b 100644 --- a/server.ts +++ b/server.ts @@ -197,12 +197,11 @@ export class SERVER { public async stop(): Promise { if (this.server) { this.controller?.abort(); - await this.server.shutdown(); - if (this.shutdown_binding) { Deno.removeSignalListener('SIGTERM', this.shutdown_binding); Deno.removeSignalListener('SIGINT', this.shutdown_binding); } + await this.server.shutdown(); } if (this.original_directory) {