mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
Fix server can not stop with Ctrl + C
This commit is contained in:
10
deno.lock
generated
10
deno.lock
generated
@@ -122,6 +122,8 @@
|
||||
"https://deno.land/x/[email protected]/wasm.d.ts": "dc279a3a46f084484453e617c0cabcd5b8bd1920c0e562e4ea02dfc828c8f968",
|
||||
"https://deno.land/x/[email protected]/wasm.js": "4030e7b50941ec6e06704c6b5f1f6416cc0f7f35f63daf63f184b728bea79a30",
|
||||
"https://deno.land/x/[email protected]/dev.ts": "a66c7d64be35bcd6a8e12eec9c27ae335044c70363a241f2e36ee776db468622",
|
||||
"https://deno.land/x/[email protected]/plugins/twind.ts": "c0570d6010e29ba24ee5f43b9d3f1fe735f7fac76d9a3e680c9896373d669876",
|
||||
"https://deno.land/x/[email protected]/plugins/twind/shared.ts": "023e0ffcd66668753b5049edab0de46e6d66194fb6026c679034b9bbf04ad6f3",
|
||||
"https://deno.land/x/[email protected]/runtime.ts": "b02ec1e2e32cf73a33d262b7c9dcab9468ce16cd89fd424196c71003698a4ab0",
|
||||
"https://deno.land/x/[email protected]/server.ts": "f379c9aad24471a71e58fb887fa57e5cc27ad9df035987eb260541c78df38e84",
|
||||
"https://deno.land/x/[email protected]/src/dev/deps.ts": "aef312af6de1315fa95fc0c32e87c56301b64efeb304193d0dce0da0634144d3",
|
||||
@@ -198,12 +200,20 @@
|
||||
"https://esm.sh/stable/[email protected]/deno/hooks.js": "f25445c4f9fa6742119c41db4a85a2f75ee6ea941c506ae8ad3b1568c7692c61",
|
||||
"https://esm.sh/stable/[email protected]/deno/jsx-runtime.js": "7c8e1b8f272996846cbac0837dcb71f6f8cfc82611b3f7819501d07c37383dc0",
|
||||
"https://esm.sh/stable/[email protected]/deno/preact.mjs": "9b73545225d0ed274c89f39aee524a2857c81a73060e80c2c4bdc2a6de7bec26",
|
||||
"https://esm.sh/[email protected]": "e6db0352eb940ca8cdbf129fe4520809916d002b8ccc2e2fc7f8551138f7a161",
|
||||
"https://esm.sh/[email protected]/sheets": "3472c3c28394aa25c026ff81a393361e71aca014b3b8db5d6c67396e60f87cc9",
|
||||
"https://esm.sh/v118/[email protected]/hooks/src/index.d.ts": "5c29febb624fc25d71cb0e125848c9b711e233337a08f7eacfade38fd4c14cc3",
|
||||
"https://esm.sh/v118/[email protected]/jsx-runtime/src/index.d.ts": "e153460ed2b3fe2ad8b93696ecd48fbf73cd628b0b0ea6692b71804a3af69dfd",
|
||||
"https://esm.sh/v118/[email protected]/src/index.d.ts": "65398710de6aa0a07412da79784e05e6e96763f51c7c91b77344d2d0af06385c",
|
||||
"https://esm.sh/v118/[email protected]/src/jsx.d.ts": "fde41cfb4944bcc5005e653c989ef8f85deb1cbb5364a1726654993937cd08d0",
|
||||
"https://esm.sh/v124/[email protected]/index.d.ts": "4c68749a564a6facdf675416d75789ee5a557afda8960e0803cf6711fa569288",
|
||||
"https://esm.sh/v124/[email protected]/X-ZS8q/deno/preact-render-to-string.mjs": "672116885c5e5072207c527a0ec663f5bc52774a0868ec487985109520382a55",
|
||||
"https://esm.sh/v124/[email protected]/X-ZS8q/src/index.d.ts": "b1d73703252c8570fdf2952475805f5808ba3511fefbd93a3e7bd8406de7dcd0",
|
||||
"https://esm.sh/v124/[email protected]/deno/style-vendorizer.mjs": "fb725497dd9621a84f552f9b6a4f3df82af5989ff18c40e972de1bdf475c9765",
|
||||
"https://esm.sh/v124/[email protected]/deno/sheets.js": "dcdb26e5d2860d9fff3ad81b81625799e501d465efdc99b206d3b7cd94151913",
|
||||
"https://esm.sh/v124/[email protected]/deno/twind.mjs": "ac4bf729653ee66349a518ee4949f22e84b7f626e8f74de1066e798a7c1ca12a",
|
||||
"https://esm.sh/v124/[email protected]/sheets/sheets.d.ts": "9cd4663d180023e49d9379777c8926347f3f79bf3bee546e7e5be1524fe55e70",
|
||||
"https://esm.sh/v124/[email protected]/twind.d.ts": "48c49da7d770f1236ec8a9397af053e6fb5a2bedacf431f2189eeecc1468c01b",
|
||||
"https://raw.githubusercontent.com/lucacasonato/esbuild_deno_loader/8031f71afa1bbcd3237a94b11f53a2e5c5c0e7bf/deps.ts": "b7248e5b750be62613a9417f407e65ed43726d83b11f9631d6dbb58634bbd7d1",
|
||||
"https://raw.githubusercontent.com/lucacasonato/esbuild_deno_loader/8031f71afa1bbcd3237a94b11f53a2e5c5c0e7bf/mod.ts": "3e507379372361162f93325a216b86f6098defb5bb60144555b507bca26d061f",
|
||||
"https://raw.githubusercontent.com/lucacasonato/esbuild_deno_loader/8031f71afa1bbcd3237a94b11f53a2e5c5c0e7bf/src/deno.ts": "71bee6b14e72ca193c0686d8b4f1f47d639a64745b6f5c7576f7a3616f436f57",
|
||||
|
||||
@@ -2,6 +2,8 @@ import { start } from "$fresh/server.ts";
|
||||
import { Config } from "./config.ts";
|
||||
import manifest from "./fresh.gen.ts";
|
||||
import { TaskManager } from "./task_manager.ts";
|
||||
import twindPlugin from "$fresh/plugins/twind.ts";
|
||||
import twindConfig from "./twind.config.ts";
|
||||
|
||||
let task_manager: TaskManager | undefined = undefined;
|
||||
|
||||
@@ -12,5 +14,8 @@ export function get_task_manager() {
|
||||
|
||||
export function startServer(cfg: Config) {
|
||||
task_manager = new TaskManager(cfg);
|
||||
return start(manifest, {});
|
||||
return start(manifest, {
|
||||
signal: task_manager.aborts,
|
||||
plugins: [twindPlugin(twindConfig)],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ export class TaskManager {
|
||||
get aborted() {
|
||||
return this.#abort.signal.aborted;
|
||||
}
|
||||
get aborts() {
|
||||
return this.#abort.signal;
|
||||
}
|
||||
async add_download_task(gid: number, token: string) {
|
||||
this.#check_closed();
|
||||
const otask = await this.db.check_download_task(gid, token);
|
||||
@@ -125,6 +128,9 @@ export class TaskManager {
|
||||
get force_aborted() {
|
||||
return this.#force_abort.signal.aborted;
|
||||
}
|
||||
get force_aborts() {
|
||||
return this.#force_abort.signal;
|
||||
}
|
||||
async run() {
|
||||
if (this.aborted || this.force_aborted) throw new AlreadyClosedError();
|
||||
this.#check_closed();
|
||||
|
||||
5
twind.config.ts
Normal file
5
twind.config.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { Options } from "$fresh/plugins/twind.ts";
|
||||
|
||||
export default {
|
||||
selfURL: import.meta.url,
|
||||
} as Options;
|
||||
Reference in New Issue
Block a user