fix: signal_listener
This commit is contained in:
parent
32c1458a9c
commit
e6d7020fc8
8
main.ts
8
main.ts
@ -9,9 +9,15 @@ import "$std/dotenv/load.ts";
|
||||
import { start } from "$fresh/server.ts";
|
||||
import manifest from "./fresh.gen.ts";
|
||||
|
||||
import twindPlugin from "$fresh/plugins/twind.ts";
|
||||
import twindPlugin from "$fresh/plugins/twindv1.ts";
|
||||
import twindConfig from "./twind.config.ts";
|
||||
|
||||
console.log("start");
|
||||
|
||||
Deno.addSignalListener("SIGINT", () => {
|
||||
Deno.exit(0);
|
||||
});
|
||||
|
||||
await start(manifest, {
|
||||
port: 12001,
|
||||
plugins: [twindPlugin(twindConfig)]
|
||||
|
15
pages.ts
15
pages.ts
@ -26,18 +26,25 @@ function watchFile(
|
||||
}
|
||||
}
|
||||
})();
|
||||
Deno.addSignalListener("SIGINT", () => {
|
||||
const closeHandler = () => {
|
||||
watcherRef.close();
|
||||
});
|
||||
};
|
||||
Deno.addSignalListener("SIGINT", closeHandler);
|
||||
return ()=>{
|
||||
Deno.removeSignalListener("SIGINT", closeHandler);
|
||||
closeHandler();
|
||||
}
|
||||
}
|
||||
|
||||
let pages_meta: PageDescription[] = [];
|
||||
let mtime = 0;
|
||||
let lastest_disposer = () => {};
|
||||
export async function get_pages_meta(): Promise<[PageDescription[],number]>{
|
||||
if (pages_meta) {
|
||||
if (pages_meta.length == 0) {
|
||||
pages_meta = await readPagesDescription();
|
||||
mtime = Date.now();
|
||||
watchFile(PAGES_PATH, async () => {
|
||||
lastest_disposer();
|
||||
lastest_disposer = watchFile(PAGES_PATH, async () => {
|
||||
pages_meta = await readPagesDescription();
|
||||
mtime = Date.now();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user