1
0

Parallel plug loading on the server

This commit is contained in:
Zef Hemel 2022-10-21 17:06:14 +02:00
parent dc32ca81a9
commit 5bb73c111d
3 changed files with 6 additions and 10 deletions

View File

@ -41,7 +41,6 @@ export async function readFileCloud(
text,
`${pagePrefix}${originalUrl.split("/")[0]}/`,
);
console.log("Got this", text);
return {
data: encoding === "string" ? text : base64EncodedDataUrl(
"text/markdown",

View File

@ -1,4 +1,4 @@
import { Application, etag, path, Router } from "./deps.ts";
import { Application, path, Router } from "./deps.ts";
import { Manifest, SilverBulletHooks } from "../common/manifest.ts";
import { loadMarkdownExtensions } from "../common/markdown_ext.ts";
import buildMarkdown from "../common/parser.ts";
@ -175,13 +175,10 @@ export class HttpServer {
const allPlugs = await this.space.listPlugs();
console.log("Loading plugs", allPlugs);
for (const plugName of allPlugs) {
await Promise.all((await this.space.listPlugs()).map(async (plugName) => {
const { data } = await this.space.readAttachment(plugName, "string");
await this.system.load(
JSON.parse(data as string),
createSandbox,
);
}
await this.system.load(JSON.parse(data as string), createSandbox);
}));
this.rebuildMdExtensions();
const corePlug = this.system.loadedPlugs.get("core");

View File

@ -42,7 +42,7 @@ import { Space } from "../common/spaces/space.ts";
import { markdownSyscalls } from "../common/syscalls/markdown.ts";
import { FilterOption, PageMeta } from "../common/types.ts";
import { safeRun, throttle } from "../common/util.ts";
import { createSandbox as createIFrameSandbox } from "../plugos/environments/webworker_sandbox.ts";
import { createSandbox } from "../plugos/environments/webworker_sandbox.ts";
import { EventHook } from "../plugos/hooks/event.ts";
import { eventSyscalls } from "../plugos/syscalls/event.ts";
import sandboxSyscalls from "../plugos/syscalls/sandbox.ts";
@ -530,7 +530,7 @@ export class Editor {
console.log("(Re)loading plugs");
await Promise.all((await this.space.listPlugs()).map(async (plugName) => {
const { data } = await this.space.readAttachment(plugName, "string");
await this.system.load(JSON.parse(data as string), createIFrameSandbox);
await this.system.load(JSON.parse(data as string), createSandbox);
}));
this.rebuildEditorState();
await this.dispatchAppEvent("plugs:loaded");