fix: try a different way to listen for the server shutdown and remove
signal listeners
This commit is contained in:
parent
4f2ea38222
commit
f63cb933dd
2 changed files with 10 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@andyburke/serverus",
|
"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.",
|
"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.5",
|
"version": "0.9.6",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./serverus.ts",
|
".": "./serverus.ts",
|
||||||
|
|
14
server.ts
14
server.ts
|
@ -196,10 +196,15 @@ export class SERVER {
|
||||||
*/
|
*/
|
||||||
public async stop(): Promise<void> {
|
public async stop(): Promise<void> {
|
||||||
if (this.server) {
|
if (this.server) {
|
||||||
if (this.shutdown_binding) {
|
this.server.finished.finally(() => {
|
||||||
Deno.removeSignalListener('SIGTERM', this.shutdown_binding);
|
if (this.shutdown_binding) {
|
||||||
Deno.removeSignalListener('SIGINT', this.shutdown_binding);
|
Deno.removeSignalListener('SIGTERM', this.shutdown_binding);
|
||||||
}
|
Deno.removeSignalListener('SIGINT', this.shutdown_binding);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.shutdown_binding = undefined;
|
||||||
|
});
|
||||||
|
|
||||||
this.controller?.abort();
|
this.controller?.abort();
|
||||||
await this.server.shutdown();
|
await this.server.shutdown();
|
||||||
}
|
}
|
||||||
|
@ -210,7 +215,6 @@ export class SERVER {
|
||||||
|
|
||||||
this.controller = undefined;
|
this.controller = undefined;
|
||||||
this.server = undefined;
|
this.server = undefined;
|
||||||
this.shutdown_binding = undefined;
|
|
||||||
this.original_directory = undefined;
|
this.original_directory = undefined;
|
||||||
|
|
||||||
for (const handler_module of this.handlers) {
|
for (const handler_module of this.handlers) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue